protomux-rpc
Advanced tools
Comparing version 1.5.2 to 1.6.0
31
index.js
@@ -94,10 +94,11 @@ const EventEmitter = require('events') | ||
if (requestEncoding) value = c.decode(requestEncoding, value) | ||
this._responding++ | ||
try { | ||
if (requestEncoding) value = c.decode(requestEncoding, value) | ||
value = await responder.handler(value) | ||
} catch (err) { | ||
safetyCatch(err) | ||
error = err.message | ||
@@ -109,3 +110,9 @@ } | ||
if (!error && responseEncoding && id) { | ||
value = c.encode(responseEncoding, value) | ||
try { | ||
value = c.encode(responseEncoding, value) | ||
} catch (err) { | ||
safetyCatch(err) | ||
error = err.message | ||
} | ||
} | ||
@@ -137,5 +144,11 @@ } | ||
if (responseEncoding) value = c.decode(responseEncoding, value) | ||
try { | ||
if (responseEncoding) value = c.decode(responseEncoding, value) | ||
request.resolve(value) | ||
request.resolve(value) | ||
} catch (err) { | ||
safetyCatch(err) | ||
request.reject(err) | ||
} | ||
} | ||
@@ -158,2 +171,6 @@ | ||
get opened () { | ||
return this._channel.opened | ||
} | ||
get closed () { | ||
@@ -171,2 +188,6 @@ return this._channel.closed | ||
async fullyOpened () { | ||
await this._channel.fullyOpened() | ||
} | ||
respond (method, options, handler) { | ||
@@ -173,0 +194,0 @@ if (typeof options === 'function') { |
{ | ||
"name": "protomux-rpc", | ||
"version": "1.5.2", | ||
"version": "1.6.0", | ||
"description": "RPC over Protomux channels", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"compact-encoding-bitfield": "^1.0.0", | ||
"protomux": "^3.2.1", | ||
"protomux": "^3.7.0", | ||
"safety-catch": "^1.0.2" | ||
@@ -36,0 +36,0 @@ }, |
@@ -65,2 +65,6 @@ # Protomux RPC | ||
#### `rpc.opened` | ||
Whether or not the RPC channel is opened. | ||
#### `rpc.mux` | ||
@@ -121,2 +125,6 @@ | ||
#### `await rpc.fullyOpened()` | ||
Resolves when the rpc is fully setup, or rejects if the setup failed. | ||
#### `await rpc.end()` | ||
@@ -123,0 +131,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24087
268
173
Updatedprotomux@^3.7.0