From a787cae027102752c4de0fa36dfb0472d97bcb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lavergne?= Date: Fri, 22 Apr 2016 13:56:18 -0400 Subject: [PATCH] Create .notify(), remove useless timers (fixes #6) --- README.md | 18 ++++++++++++------ jrpc.browser.js | 31 ++++++++++++++++++++++--------- jrpc.js | 31 ++++++++++++++++++++++--------- jrpc.min.js | 4 ++-- jrpc.min.js.map | 2 +- package.json | 2 +- test.js | 17 ++++++++++++++--- 7 files changed, 74 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 8633c31..47ba0ef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# jrpc v3.0.1-beta +# jrpc v3.0.2-beta -[![Build Status](https://travis-ci.org/vphantom/js-jrpc.svg?branch=v3.0.1-beta)](https://travis-ci.org/vphantom/js-jrpc) [![Coverage Status](https://coveralls.io/repos/github/vphantom/js-jrpc/badge.svg?branch=v3.0.1-beta)](https://coveralls.io/github/vphantom/js-jrpc?branch=v3.0.1-beta) +[![Build Status](https://travis-ci.org/vphantom/js-jrpc.svg?branch=v3.0.2-beta)](https://travis-ci.org/vphantom/js-jrpc) [![Coverage Status](https://coveralls.io/repos/github/vphantom/js-jrpc/badge.svg?branch=v3.0.2-beta)](https://coveralls.io/github/vphantom/js-jrpc?branch=v3.0.2-beta) Streaming bidirectional backwards-compatible extended JSON-RPC 2.0 in JavaScript @@ -167,6 +167,8 @@ remote.expose('foo.bar', function(params, next) { }); ``` +Due to the nature of JSON-RPC, even methods intended to be used as notification receivers need to call `next()` with at least one parameter, so that if the method is accidentally called requesting a value, one will reach the caller. A simple `next(true)` suffices. + ### remote.expose(*object*) Add many declarations at once: @@ -190,18 +192,18 @@ If you are using JRPC on the client side and know in advance that the remote ser Note that it is important to handshake _after_ having exposed your service methods, because afterwards the other end will be limited to calling method names which have been already exposed at this point. (See `remote.call()` below.) -### remote.call(*methodName*, *params*, *callback*) +### remote.call(*methodName*[, *params*][, *callback*]]) ##### Bluebird: remote.callAsync(*methodName*, *params*) -Queue a call to the other end's method `methodName` with `params` as a single argument. Your callback is _guaranteed_ to be invoked even if the server never responds, in which case it would be in error, after a timeout. +Queue a call to the other end's method `methodName` with `params` as a single argument. If you supplied a callback, it is _guaranteed_ to be invoked even if the server never responds, in which case it would be in error, after a timeout. Note that omitting a callback prevents your application from detecting errors, so it should usually be reserved for methods which return no value (called "notifications" in JSON-RPC 2.0). Note that after a successful `remote.upgrade()`, any attempts to call a `methodName` not disclosed by the remote end during capability handshake will immediately fail. This is to save on useless network round-trips. -While it is up to implementations to decide what to do with `params`: either an Array or an object (alas, no bare values per the specification). I recommend an object so that properties can be named and future changes have less risk of breaking anything. +While it is up to implementations to decide what to do with `params`: either an Array or an object (alas, no bare values per the specification). Specifying `null` is equivalent to omitting it entirely. I recommend an object so that properties can be named and future changes have less risk of breaking anything. ```js -remote._call('foo', [], function(err, result) { +remote.call('foo', {}, function(err, result) { if (err) { // Something went wrong... } else { @@ -228,6 +230,10 @@ var fooResult = yield remote.callAsync('foo', {}); It is **strongly recommended** to keep a non-zero remoteTimeout when using co-routines! +### remote.notify(*methodName*[, *params*]) + +Convenience shortcut to `remote.call()` so that your code can more clearly distinguish between method calls expecting a return value and one-way notifications. + ### remote.receive(*message*) Parse `message` as a JSON-RPC 2.0 request or response. If it's a request, responses will be created and transmitted back (or queued). If it's a response, callers will receive what they were waiting for. diff --git a/jrpc.browser.js b/jrpc.browser.js index 108e554..5912624 100644 --- a/jrpc.browser.js +++ b/jrpc.browser.js @@ -1,6 +1,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JRPC = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o * Copyright 2016 Stéphane Lavergne * Free software under MIT License: */ @@ -261,8 +261,8 @@ function upgrade() { * Queue up a remote method call * * @param {string} methodName Name of method to call - * @param {(Object|Array|null)} params Parameters - * @param {JRPC~receiveCallback} next Callback to receive result + * @param {(Object|Array|null)} [params] Parameters + * @param {JRPC~receiveCallback} [next] Callback to receive result * * @return {JRPC} This instance, for chaining */ @@ -272,15 +272,22 @@ function call(methodName, params, next) { method : methodName }; + if (typeof params === 'function') { + next = params; + params = null; + } + if ( 'system._upgraded' in this.remoteComponents && !(methodName in this.remoteComponents) ) { // We're upgraded, yet method name isn't found, immediate error! - setImmediate(next, { - code : -32601, - message: 'Unknown remote method' - }); + if (typeof next === 'function') { + setImmediate(next, { + code : -32601, + message: 'Unknown remote method' + }); + } return this; } @@ -290,12 +297,17 @@ function call(methodName, params, next) { request.params = params; } - this.inbox[this.serial] = next; + if (typeof next === 'function') { + this.inbox[this.serial] = next; + } this.outbox.requests.push(request); // If we're interactive, send the new request this.transmit(); + if (typeof next !== 'function') { + return this; + } if (this.remoteTimeout > 0) { this.outTimers[this.serial] = setTimeout( deliverResponse.bind( @@ -476,7 +488,7 @@ function serveRequest(request) { setImmediate( this.exposed[request.method], params, - sendResponse.bind(this, id) + sendResponse.bind(this, id) // id will be unknown, thus will be silent ); return; @@ -556,6 +568,7 @@ function sendResponse(id, err, result, timeout) { // Public methods JRPC.prototype.call = call; +JRPC.prototype.notify = call; JRPC.prototype.expose = expose; JRPC.prototype.upgrade = upgrade; JRPC.prototype.receive = receive; diff --git a/jrpc.js b/jrpc.js index bb9c4f3..93a7737 100644 --- a/jrpc.js +++ b/jrpc.js @@ -1,4 +1,4 @@ -/*! JRPC v3.0.1-beta +/*! JRPC v3.0.2-beta * * Copyright 2016 Stéphane Lavergne * Free software under MIT License: */ @@ -259,8 +259,8 @@ function upgrade() { * Queue up a remote method call * * @param {string} methodName Name of method to call - * @param {(Object|Array|null)} params Parameters - * @param {JRPC~receiveCallback} next Callback to receive result + * @param {(Object|Array|null)} [params] Parameters + * @param {JRPC~receiveCallback} [next] Callback to receive result * * @return {JRPC} This instance, for chaining */ @@ -270,15 +270,22 @@ function call(methodName, params, next) { method : methodName }; + if (typeof params === 'function') { + next = params; + params = null; + } + if ( 'system._upgraded' in this.remoteComponents && !(methodName in this.remoteComponents) ) { // We're upgraded, yet method name isn't found, immediate error! - setImmediate(next, { - code : -32601, - message: 'Unknown remote method' - }); + if (typeof next === 'function') { + setImmediate(next, { + code : -32601, + message: 'Unknown remote method' + }); + } return this; } @@ -288,12 +295,17 @@ function call(methodName, params, next) { request.params = params; } - this.inbox[this.serial] = next; + if (typeof next === 'function') { + this.inbox[this.serial] = next; + } this.outbox.requests.push(request); // If we're interactive, send the new request this.transmit(); + if (typeof next !== 'function') { + return this; + } if (this.remoteTimeout > 0) { this.outTimers[this.serial] = setTimeout( deliverResponse.bind( @@ -474,7 +486,7 @@ function serveRequest(request) { setImmediate( this.exposed[request.method], params, - sendResponse.bind(this, id) + sendResponse.bind(this, id) // id will be unknown, thus will be silent ); return; @@ -554,6 +566,7 @@ function sendResponse(id, err, result, timeout) { // Public methods JRPC.prototype.call = call; +JRPC.prototype.notify = call; JRPC.prototype.expose = expose; JRPC.prototype.upgrade = upgrade; JRPC.prototype.receive = receive; diff --git a/jrpc.min.js b/jrpc.min.js index a83f817..4e3531e 100644 --- a/jrpc.min.js +++ b/jrpc.min.js @@ -1,6 +1,6 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.JRPC=e()}}(function(){return function e(t,o,i){function s(r,u){if(!o[r]){if(!t[r]){var l="function"==typeof require&&require;if(!u&&l)return l(r,!0);if(n)return n(r,!0);var m=new Error("Cannot find module '"+r+"'");throw m.code="MODULE_NOT_FOUND",m}var a=o[r]={exports:{}};t[r][0].call(a.exports,function(e){var o=t[r][1][e];return s(o?o:e)},a,a.exports,e,t,o,i)}return o[r].exports}for(var n="function"==typeof require&&require,r=0;r * Copyright 2016 Stéphane Lavergne * Free software under MIT License: */ -"use strict";function i(e){this.transmitter=null,this.remoteTimeout=6e4,this.localTimeout=0,this.serial=0,this.discardSerial=0,this.outbox={requests:[],responses:[]},this.inbox={},this.localTimers={},this.outTimers={},this.localComponents={"system.listComponents":!0,"system.extension.dual-batch":!0},this.remoteComponents={},this.exposed={},this.exposed["system.listComponents"]=function(e,t){return"object"==typeof e&&(this.remoteComponents=e,this.remoteComponents["system._upgraded"]=!0),t(null,this.localComponents)}.bind(this),this.exposed["system.extension.dual-batch"]=function(e,t){return t(null,!0)},"object"==typeof e&&("remoteTimeout"in e&&"number"==typeof e.remoteTimeout&&(this.remoteTimeout=1e3*e.remoteTimeout),"localTimeout"in e&&"number"==typeof e.localTimeout&&(this.localTimeout=1e3*e.localTimeout))}function s(e){var t,o,i=null,s={responses:[],requests:[]};if("function"!=typeof e&&(e=this.transmitter),"function"!=typeof e)return this;if(t=this.outbox.responses.length,o=this.outbox.requests.length,t>0&&o>0&&"system.extension.dual-batch"in this.remoteComponents)s=i={responses:this.outbox.responses,requests:this.outbox.requests},this.outbox.responses=[],this.outbox.requests=[];else if(t>0)t>1?(s.responses=i=this.outbox.responses,this.outbox.responses=[]):s.responses.push(i=this.outbox.responses.pop());else{if(!(o>0))return this;o>1?(s.requests=i=this.outbox.requests,this.outbox.requests=[]):s.requests.push(i=this.outbox.requests.pop())}return setImmediate(e,JSON.stringify(i),r.bind(this,s)),this}function n(e){return this.transmitter=e,this.transmit()}function r(e,t){t&&(e.responses.length>0&&Array.prototype.push.apply(this.outbox.responses,e.responses),e.requests.length>0&&Array.prototype.push.apply(this.outbox.requests,e.requests))}function u(e){var t=[],o=[];if("string"==typeof e)try{e=JSON.parse(e)}catch(i){return this}if(e.constructor===Array){if(0===e.length)return this;"string"==typeof e[0].method?t=e:o=e}else"object"==typeof e&&("undefined"!=typeof e.requests&&"undefined"!=typeof e.responses?(t=e.requests,o=e.responses):"string"==typeof e.method?t.push(e):o.push(e));return o.forEach(a.bind(this)),t.forEach(c.bind(this)),this}function l(){return this.call("system.listComponents",this.localComponents,function(e,t){e||"object"!=typeof t||(this.remoteComponents=t,this.remoteComponents["system._upgraded"]=!0)}.bind(this))}function m(e,t,o){var i={jsonrpc:"2.0",method:e};return"system._upgraded"in this.remoteComponents&&!(e in this.remoteComponents)?(setImmediate(o,{code:-32601,message:"Unknown remote method"}),this):(this.serial++,i.id=this.serial,"object"==typeof t&&(i.params=t),this.inbox[this.serial]=o,this.outbox.requests.push(i),this.transmit(),this.remoteTimeout>0?this.outTimers[this.serial]=setTimeout(a.bind(this,{jsonrpc:"2.0",id:this.serial,error:{code:-1e3,message:"Timed out waiting for response"}},!0),this.remoteTimeout):this.outTimers[this.serial]=!0,this)}function a(e,t){var o=!1,i=null;"id"in e&&e.id in this.outTimers&&(t===!0&&clearTimeout(this.outTimers[e.id]),delete this.outTimers[e.id],"id"in e&&e.id in this.inbox&&("error"in e?o=e.error:i=e.result,setImmediate(this.inbox[e.id],o,i),delete this.inbox[e.id]))}function p(e,t){var o;if("string"==typeof e)this.localComponents[e]=!0,this.exposed[e]=t;else if("object"==typeof e)for(o in e)e.hasOwnProperty(o)&&(this.localComponents[o]=!0,this.exposed[o]=e[o]);return this}function c(e){var t=null,o=null;if("object"==typeof e&&null!==e&&"string"==typeof e.jsonrpc&&"2.0"===e.jsonrpc){if(t="undefined"!=typeof e.id?e.id:null,"string"!=typeof e.method)return void(null!==t&&(this.localTimers[t]=!0,setImmediate(h.bind(this,t,-32600))));if(!(e.method in this.exposed))return void(null!==t&&(this.localTimers[t]=!0,setImmediate(h.bind(this,t,-32601))));if("params"in e){if("object"!=typeof e.params)return void(null!==t&&(this.localTimers[t]=!0,setImmediate(h.bind(this,t,-32602))));o=e.params}null===t&&(this.discardSerial--,t=this.discardSerial),this.localTimeout>0?this.localTimers[t]=setTimeout(h.bind(this,t,{code:-1002,message:"Method handler timed out"},void 0,!0),this.localTimeout):this.localTimers[t]=!0,setImmediate(this.exposed[e.method],o,h.bind(this,t))}}function h(e,t,o,i){var s={jsonrpc:"2.0",id:e};e in this.localTimers&&(i===!0&&clearTimeout(this.localTimers[e]),delete this.localTimers[e],null===e||0>e||("undefined"!=typeof t&&null!==t&&t!==!1?"number"==typeof t?s.error={code:t,message:"error"}:t===!0?s.error={code:-1,message:"error"}:"string"==typeof t?s.error={code:-1,message:t}:"object"==typeof t&&"code"in t&&"message"in t?s.error=t:s.error={code:-2,message:"error",data:t}:s.result=o,this.outbox.responses.push(s),this.transmit()))}o.setImmediate=e("timers").setImmediate,i.prototype.call=m,i.prototype.expose=p,i.prototype.upgrade=l,i.prototype.receive=u,i.prototype.transmit=s,i.prototype.setTransmitter=n,"function"==typeof Promise.promisify&&(i.prototype.callAsync=Promise.promisify(m)),t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{timers:3}],2:[function(e,t,o){function i(){a=!1,u.length?m=u.concat(m):p=-1,m.length&&s()}function s(){if(!a){var e=setTimeout(i);a=!0;for(var t=m.length;t;){for(u=m,m=[];++p1)for(var o=1;o=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},o.setImmediate="function"==typeof setImmediate?setImmediate:function(e){var t=l++,i=arguments.length<2?!1:r.call(arguments,1);return u[t]=!0,s(function(){u[t]&&(i?e.apply(null,i):e.call(null),o.clearImmediate(t))}),t},o.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(e){delete u[e]}},{"process/browser.js":2}]},{},[1])(1)}); +"use strict";function i(e){this.transmitter=null,this.remoteTimeout=6e4,this.localTimeout=0,this.serial=0,this.discardSerial=0,this.outbox={requests:[],responses:[]},this.inbox={},this.localTimers={},this.outTimers={},this.localComponents={"system.listComponents":!0,"system.extension.dual-batch":!0},this.remoteComponents={},this.exposed={},this.exposed["system.listComponents"]=function(e,t){return"object"==typeof e&&(this.remoteComponents=e,this.remoteComponents["system._upgraded"]=!0),t(null,this.localComponents)}.bind(this),this.exposed["system.extension.dual-batch"]=function(e,t){return t(null,!0)},"object"==typeof e&&("remoteTimeout"in e&&"number"==typeof e.remoteTimeout&&(this.remoteTimeout=1e3*e.remoteTimeout),"localTimeout"in e&&"number"==typeof e.localTimeout&&(this.localTimeout=1e3*e.localTimeout))}function s(e){var t,o,i=null,s={responses:[],requests:[]};if("function"!=typeof e&&(e=this.transmitter),"function"!=typeof e)return this;if(t=this.outbox.responses.length,o=this.outbox.requests.length,t>0&&o>0&&"system.extension.dual-batch"in this.remoteComponents)s=i={responses:this.outbox.responses,requests:this.outbox.requests},this.outbox.responses=[],this.outbox.requests=[];else if(t>0)t>1?(s.responses=i=this.outbox.responses,this.outbox.responses=[]):s.responses.push(i=this.outbox.responses.pop());else{if(!(o>0))return this;o>1?(s.requests=i=this.outbox.requests,this.outbox.requests=[]):s.requests.push(i=this.outbox.requests.pop())}return setImmediate(e,JSON.stringify(i),r.bind(this,s)),this}function n(e){return this.transmitter=e,this.transmit()}function r(e,t){t&&(e.responses.length>0&&Array.prototype.push.apply(this.outbox.responses,e.responses),e.requests.length>0&&Array.prototype.push.apply(this.outbox.requests,e.requests))}function u(e){var t=[],o=[];if("string"==typeof e)try{e=JSON.parse(e)}catch(i){return this}if(e.constructor===Array){if(0===e.length)return this;"string"==typeof e[0].method?t=e:o=e}else"object"==typeof e&&("undefined"!=typeof e.requests&&"undefined"!=typeof e.responses?(t=e.requests,o=e.responses):"string"==typeof e.method?t.push(e):o.push(e));return o.forEach(m.bind(this)),t.forEach(c.bind(this)),this}function l(){return this.call("system.listComponents",this.localComponents,function(e,t){e||"object"!=typeof t||(this.remoteComponents=t,this.remoteComponents["system._upgraded"]=!0)}.bind(this))}function p(e,t,o){var i={jsonrpc:"2.0",method:e};return"function"==typeof t&&(o=t,t=null),"system._upgraded"in this.remoteComponents&&!(e in this.remoteComponents)?("function"==typeof o&&setImmediate(o,{code:-32601,message:"Unknown remote method"}),this):(this.serial++,i.id=this.serial,"object"==typeof t&&(i.params=t),"function"==typeof o&&(this.inbox[this.serial]=o),this.outbox.requests.push(i),this.transmit(),"function"!=typeof o?this:(this.remoteTimeout>0?this.outTimers[this.serial]=setTimeout(m.bind(this,{jsonrpc:"2.0",id:this.serial,error:{code:-1e3,message:"Timed out waiting for response"}},!0),this.remoteTimeout):this.outTimers[this.serial]=!0,this))}function m(e,t){var o=!1,i=null;"id"in e&&e.id in this.outTimers&&(t===!0&&clearTimeout(this.outTimers[e.id]),delete this.outTimers[e.id],"id"in e&&e.id in this.inbox&&("error"in e?o=e.error:i=e.result,setImmediate(this.inbox[e.id],o,i),delete this.inbox[e.id]))}function a(e,t){var o;if("string"==typeof e)this.localComponents[e]=!0,this.exposed[e]=t;else if("object"==typeof e)for(o in e)e.hasOwnProperty(o)&&(this.localComponents[o]=!0,this.exposed[o]=e[o]);return this}function c(e){var t=null,o=null;if("object"==typeof e&&null!==e&&"string"==typeof e.jsonrpc&&"2.0"===e.jsonrpc){if(t="undefined"!=typeof e.id?e.id:null,"string"!=typeof e.method)return void(null!==t&&(this.localTimers[t]=!0,setImmediate(f.bind(this,t,-32600))));if(!(e.method in this.exposed))return void(null!==t&&(this.localTimers[t]=!0,setImmediate(f.bind(this,t,-32601))));if("params"in e){if("object"!=typeof e.params)return void(null!==t&&(this.localTimers[t]=!0,setImmediate(f.bind(this,t,-32602))));o=e.params}null===t&&(this.discardSerial--,t=this.discardSerial),this.localTimeout>0?this.localTimers[t]=setTimeout(f.bind(this,t,{code:-1002,message:"Method handler timed out"},void 0,!0),this.localTimeout):this.localTimers[t]=!0,setImmediate(this.exposed[e.method],o,f.bind(this,t))}}function f(e,t,o,i){var s={jsonrpc:"2.0",id:e};e in this.localTimers&&(i===!0&&clearTimeout(this.localTimers[e]),delete this.localTimers[e],null===e||0>e||("undefined"!=typeof t&&null!==t&&t!==!1?"number"==typeof t?s.error={code:t,message:"error"}:t===!0?s.error={code:-1,message:"error"}:"string"==typeof t?s.error={code:-1,message:t}:"object"==typeof t&&"code"in t&&"message"in t?s.error=t:s.error={code:-2,message:"error",data:t}:s.result=o,this.outbox.responses.push(s),this.transmit()))}o.setImmediate=e("timers").setImmediate,i.prototype.call=p,i.prototype.notify=p,i.prototype.expose=a,i.prototype.upgrade=l,i.prototype.receive=u,i.prototype.transmit=s,i.prototype.setTransmitter=n,"function"==typeof Promise.promisify&&(i.prototype.callAsync=Promise.promisify(p)),t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{timers:3}],2:[function(e,t,o){function i(){m=!1,u.length?p=u.concat(p):a=-1,p.length&&s()}function s(){if(!m){var e=setTimeout(i);m=!0;for(var t=p.length;t;){for(u=p,p=[];++a1)for(var o=1;o=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},o.setImmediate="function"==typeof setImmediate?setImmediate:function(e){var t=l++,i=arguments.length<2?!1:r.call(arguments,1);return u[t]=!0,s(function(){u[t]&&(i?e.apply(null,i):e.call(null),o.clearImmediate(t))}),t},o.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(e){delete u[e]}},{"process/browser.js":2}]},{},[1])(1)}); //# sourceMappingURL=jrpc.min.js.map \ No newline at end of file diff --git a/jrpc.min.js.map b/jrpc.min.js.map index 3dec9dd..0eb5bd7 100644 --- a/jrpc.min.js.map +++ b/jrpc.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["jrpc.browser.js"],"names":["f","exports","module","define","amd","g","window","global","self","this","JRPC","e","t","n","r","s","o","u","a","require","i","Error","code","l","call","length",1,"options","transmitter","remoteTimeout","localTimeout","serial","discardSerial","outbox","requests","responses","inbox","localTimers","outTimers","localComponents","system.listComponents","system.extension.dual-batch","remoteComponents","exposed","params","next","bind","transmit","callback","iRes","iReq","msg","outpacket","push","pop","setImmediate","JSON","stringify","confirmTransmit","setTransmitter","err","Array","prototype","apply","receive","parse","constructor","method","forEach","deliverResponse","serveRequest","upgrade","result","methodName","request","jsonrpc","message","id","setTimeout","error","res","timeout","clearTimeout","expose","subject","name","hasOwnProperty","sendResponse","undefined","response","data","Promise","promisify","callAsync","timers",2,"cleanUpNextTick","draining","currentQueue","queue","concat","queueIndex","drainQueue","len","run","Item","fun","array","noop","process","nextTick","args","arguments","title","browser","env","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","emit","binding","cwd","chdir","dir","umask",3,"Timeout","clearFn","_id","_clearFn","Function","slice","immediateIds","nextImmediateId","setInterval","clearInterval","close","unref","ref","enroll","item","msecs","_idleTimeoutId","_idleTimeout","unenroll","_unrefActive","active","_onTimeout","fn","clearImmediate","process/browser.js"],"mappings":"CAAA,SAAUA,GAAG,GAAoB,gBAAVC,UAAoC,mBAATC,QAAsBA,OAAOD,QAAQD,QAAS,IAAmB,kBAATG,SAAqBA,OAAOC,IAAKD,UAAUH,OAAO,CAAC,GAAIK,EAAkCA,GAAb,mBAATC,QAAwBA,OAA+B,mBAATC,QAAwBA,OAA6B,mBAAPC,MAAsBA,KAAYC,KAAKJ,EAAEK,KAAOV,MAAO,WAAqC,MAAO,SAAUW,GAAEC,EAAEC,EAAEC,GAAG,QAASC,GAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,GAAIE,GAAkB,kBAATC,UAAqBA,OAAQ,KAAIF,GAAGC,EAAE,MAAOA,GAAEF,GAAE,EAAI,IAAGI,EAAE,MAAOA,GAAEJ,GAAE,EAAI,IAAIhB,GAAE,GAAIqB,OAAM,uBAAuBL,EAAE,IAAK,MAAMhB,GAAEsB,KAAK,mBAAmBtB,EAAE,GAAIuB,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D,EAAKE,eAAiBtE,WAAW,WAC3BoE,EAAKO,YACPP,EAAKO,cACNN,KAKPlJ,EAAQsD,aAAuC,kBAAjBA,cAA8BA,aAAe,SAASmG,GAClF,GAAI7E,GAAK8D,IACL5B,EAAOC,UAAUvF,OAAS,GAAI,EAAQgH,EAAMjH,KAAKwF,UAAW,EAkBhE,OAhBA0B,GAAa7D,IAAM,EAEnBiC,EAAS,WACH4B,EAAa7D,KAGXkC,EACF2C,EAAG3F,MAAM,KAAMgD,GAEf2C,EAAGlI,KAAK,MAGVvB,EAAQ0J,eAAe9E,MAIpBA,GAGT5E,EAAQ0J,eAA2C,kBAAnBA,gBAAgCA,eAAiB,SAAS9E,SACjF6D,GAAa7D,MAEnB+E,qBAAqB,SAAS,IAAI","file":"jrpc.min.js"} \ No newline at end of file +{"version":3,"sources":["jrpc.browser.js"],"names":["f","exports","module","define","amd","g","window","global","self","this","JRPC","e","t","n","r","s","o","u","a","require","i","Error","code","l","call","length",1,"options","transmitter","remoteTimeout","localTimeout","serial","discardSerial","outbox","requests","responses","inbox","localTimers","outTimers","localComponents","system.listComponents","system.extension.dual-batch","remoteComponents","exposed","params","next","bind","transmit","callback","iRes","iReq","msg","outpacket","push","pop","setImmediate","JSON","stringify","confirmTransmit","setTransmitter","err","Array","prototype","apply","receive","parse","constructor","method","forEach","deliverResponse","serveRequest","upgrade","result","methodName","request","jsonrpc","message","id","setTimeout","error","res","timeout","clearTimeout","expose","subject","name","hasOwnProperty","sendResponse","undefined","response","data","notify","Promise","promisify","callAsync","timers",2,"cleanUpNextTick","draining","currentQueue","queue","concat","queueIndex","drainQueue","len","run","Item","fun","array","noop","process","nextTick","args","arguments","title","browser","env","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","emit","binding","cwd","chdir","dir","umask",3,"Timeout","clearFn","_id","_clearFn","Function","slice","immediateIds","nextImmediateId","setInterval","clearInterval","close","unref","ref","enroll","item","msecs","_idleTimeoutId","_idleTimeout","unenroll","_unrefActive","active","_onT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file":"jrpc.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index c88d3b8..2110e70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jrpc", - "version": "3.0.1-beta", + "version": "3.0.2-beta", "description": "Streaming bidirectional backwards-compatible extended JSON-RPC 2.0 in JavaScript", "main": "jrpc.js", "scripts": { diff --git a/test.js b/test.js index 1ef80a6..6e9be0b 100644 --- a/test.js +++ b/test.js @@ -242,7 +242,7 @@ test('I/O and timeouts', function(t) { var end1 = new JRPC({remoteTimeout: 0.35, localTimeout: 0.15}); var end2 = new JRPC({remoteTimeout: 0.35, localTimeout: 0}); - t.plan(21); + t.plan(22); end1.expose('echo', testEcho); end1.expose('errorTrue', testErrorTrue); @@ -360,7 +360,7 @@ test('I/O and timeouts', function(t) { 'receiver upgraded successfully' ); - end1.call('non-existent', [], function(err) { + end1.call('non-existent', function(err) { t.ok(err, 'call to non-existent method yields error'); t.equals(err.code, -32601, 'call to non-existent method yields error -32601'); }); @@ -373,6 +373,17 @@ test('I/O and timeouts', function(t) { } }); + end1.expose('listen', function(params, next) { + t.deepEquals( + params, + ['test notification'], + 'call without callback (notification) made it through' + ); + next(true); + }); + end2.remoteComponents['listen'] = true; + end2.notify('listen', ['test notification']); + end1.call('slow', ['expecting network timeout'], function(err, res) { if (err) { t.equals( @@ -397,7 +408,7 @@ test('I/O and timeouts', function(t) { } }); - end1.call('errorTrue', [], function(err) { + end1.call('errorTrue', function(err) { t.equals( err.code, -1,