Created
October 3, 2016 19:41
-
-
Save ConnorRigby/7624100074f0258091d2670833e88e7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Farmbot.prototype._onmessage = function (_, buffer /*, message*/) { | |
var msg = JSON.parse(buffer.toString()); | |
if(msg && (msg.method && msg.params && (msg.id === null))) { | |
console.log("Notification"); | |
this.emit("notification", msg); | |
return; | |
} | |
if(msg && (msg.id)){ | |
this.emit(msg.id, msg); | |
return; | |
} | |
throw new Error("Not a JSONRPC Compliant message") | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment