Skip to content

Instantly share code, notes, and snippets.

@ConnorRigby
Created October 3, 2016 19:41
Show Gist options
  • Save ConnorRigby/7624100074f0258091d2670833e88e7b to your computer and use it in GitHub Desktop.
Save ConnorRigby/7624100074f0258091d2670833e88e7b to your computer and use it in GitHub Desktop.
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