libkernel
Advanced tools
Comparing version 0.0.34 to 0.0.35
@@ -39,3 +39,3 @@ // log provides a wrapper for console.log that prefixes 'libkernel'. | ||
// the bridge is working. | ||
function handleBridgeResponse(data, promise) { | ||
function handleBridgeResponse(data) { | ||
// Check whether the timeout for the bridge has already fired. If so, | ||
@@ -50,6 +50,6 @@ // log that the bridge is available but late. | ||
if (!("version" in data)) { | ||
promise.resolve("bridge did not report a version"); | ||
bridgeAvailable.resolve("bridge did not report a version"); | ||
} | ||
else { | ||
promise.resolve(data.version); | ||
bridgeAvailable.resolve(data.version); | ||
} | ||
@@ -87,9 +87,15 @@ } | ||
} | ||
// Check for a bridgeTestResponse. | ||
if (event.data.method === "bridgeTestResponse") { | ||
if (event.data.nonce === 0) { | ||
handleBridgeResponse(event.data); | ||
return; | ||
} | ||
else { | ||
logErr("received bridgeTestResponse with incorrect nonce"); | ||
return; | ||
} | ||
} | ||
let promise = queries[event.data.nonce]; | ||
delete queries[event.data.nonce]; | ||
// Pass the promise to the appropriate handler. | ||
if (event.data.method === "bridgeTestResponse") { | ||
handleBridgeResponse(event.data, promise); | ||
return; | ||
} | ||
if (event.data.method === "kernelResponse") { | ||
@@ -120,3 +126,3 @@ handleKernelResponse(event.data, promise); | ||
}); | ||
queries[0] = blockForBridge; | ||
queries[0] = bridgeAvailable; | ||
// After 2 seconds, check whether the bridge has responded. If not, | ||
@@ -123,0 +129,0 @@ // fail the bridge. |
{ | ||
"name": "libkernel", | ||
"version": "0.0.34", | ||
"version": "0.0.35", | ||
"description": "helper library to interact with the skynet kernel", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
11381
291