Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bug] fix bugs in core - detected by lisenter testcase

  • Loading branch information...
commit 054cc48e508c67d3c490409fe7e6046cb0941b38 1 parent 63dbb08
@AndreasMadsen authored
Showing with 10 additions and 3 deletions.
  1. +3 −1 lib/core/lisenter.js
  2. +7 −2 lib/core/requester.js
View
4 lib/core/lisenter.js
@@ -78,6 +78,7 @@
// emit close if all layers are ofline (layer map is empty)
if (Object.keys(self.layers).length === 0) {
+ self.online = false;
self.emit('close');
}
});
@@ -140,6 +141,7 @@
// in case no errors was throwed
func.apply({
callback: function () {
+ self.root.emit('request', null, method, args, helpers.toArray(arguments));
self.callback(true, helpers.toArray(arguments));
}
}, args);
@@ -152,7 +154,7 @@
if (!(err instanceof Error)) {
error = new Error(err);
}
-
+ self.root.emit('request', error, method, args, null);
this.callback(false, helpers.error2object(error));
}
};
View
9 lib/core/requester.js
@@ -111,8 +111,6 @@
// request a method from the listener
function request(parent, name, args) {
- var layer = parent.communication;
-
// check online
if (!parent.root.online) {
parent.root.emit('error', new Error("Could not make a request, channel is offline"));
@@ -124,6 +122,13 @@
// store callback for later
var callback = args.pop();
+ // check that a callback is set
+ if (typeof callback !== 'function') {
+ parent.root.emit('error', new TypeError("No callback specified"));
+ return;
+ }
+
+ // send request to remote
parent.send('call', [name, args], function (sucess, content) {
if (sucess) {
callback.apply({
Please sign in to comment.
Something went wrong with that request. Please try again.