Created
May 20, 2019 21:41
-
-
Save maciejkorsan/167519ef993979149d7bb50f37ce7876 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let ws = new WebSocket(socketUrl) | |
ws.on("open", function open() { | |
console.log("Connected 🚀") | |
}); | |
ws.on("message", function incoming(data) { | |
const parsed = JSON.parse(data) | |
const message = parsed.payload | |
const light = message.light | |
const status = parseInt(message.status) | |
if (light === "front") { | |
lights.front = lights.front ? 0 : 1 | |
frontLeft.writeSync(lights.front) | |
frontRight.writeSync(lights.front) | |
updateStatus("front", lights.front) | |
console.log("front lights") | |
} | |
} | |
. | |
. | |
. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment