Comparing version 0.1.6 to 0.1.7
@@ -8,3 +8,3 @@ { | ||
"description": "Smith is an RPC agent system for Node.JS used in architect and vfs.", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"scripts": { | ||
@@ -11,0 +11,0 @@ "test": "./test-all.sh" |
48
smith.js
@@ -637,4 +637,52 @@ /* | ||
exports.EngineIoTransport = EngineIoTransport; | ||
inherits(EngineIoTransport, Transport); | ||
function EngineIoTransport(socket) { | ||
var self = this; | ||
// Route errors from socket to transport. | ||
socket.on("error", function (err) { | ||
self.emit("error", err); | ||
}); | ||
// Parse and route messages from socket to transport. | ||
socket.on("message", function (json) { | ||
var message; | ||
try { | ||
message = JSON.parse(json); | ||
} | ||
catch (err) { | ||
self.emit("error", err); | ||
return; | ||
} | ||
if (Array.isArray(message)) { | ||
self.emit("message", message); | ||
} | ||
else { | ||
self.emit("legacy", message); | ||
} | ||
}); | ||
// Route close events as disconnect events | ||
socket.on("close", function (reason) { | ||
self.emit("disconnect", reason); | ||
}); | ||
// Encode and route send calls to socket. | ||
this.send = function (message) { | ||
var json; | ||
try { | ||
json = JSON.stringify(message); | ||
} | ||
catch (err) { | ||
self.emit("error", err); | ||
return; | ||
} | ||
return socket.send(json); | ||
}; | ||
} | ||
return exports; | ||
}); |
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
52748
1046