Socketio Data Undefined
I'm trying to send data from my client to my server side. I only get undefined. I would like the user to click the ledOn function to send 1 and also click the ledOff to send 0 to
Solution 1:
Change client.js
to emit some data in the case of an "ON"
or "OFF"
event. For example, below, I am sending a "1"
and "0"
in ledOn()
and ledOff()
respectively.
functionledOn() {
socket.emit ('ON', "1");
document.getElementById("ON").value = "1"console.log("LED is on");
}
functionledOff() {
socket.emit('OFF', "0");
document.getElementById("OFF").value = "0"console.log("LED is off");
}
Check out the Socket.IO docs to see some of their examples.
Post a Comment for "Socketio Data Undefined"