You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I´m working with a controll application, a web gui with buttons passing data to backend and further to some hardware.
I having trouble to get my event listener to work with socket.io. I can log my click in frontend but it will never get logged in backend. Someone that can point me in the right direction?
Here is a part of the frontend code. The button click gets logged in frontend. I´m trying to pass a string to backend with no success.
const ch3MuteHp = document.createElement("button")
ch3MuteHp.id = "mute3Hp"
ch3MuteHp.style.background = muteColor
ch3MuteHp.classList.add("small-button")
ch3MuteHp.innerHTML = "Mute HP"
document.getElementById("pos3mutehp").appendChild(ch3MuteHp)
ch3MuteHp.addEventListener("click", () => {
console.log("Click") //Gets logged in front end
const isClicked = "true";
socket.emit("CH3hp", isClicked) //This seems not to fire ?
})
This is the receiving part in the backend, no log output what so ever, not even the static text( Is clicked: )
socket.on("CH3hp",(isClicked) => {
console.log(`Is clicked: ${isClicked}`); //Nothing gets logged her in the backend, even the static text is missing
})
This code runs on a raspi so i tail the syslog. The only thing that gets logged is the ws connection:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi!
I´m working with a controll application, a web gui with buttons passing data to backend and further to some hardware.
I having trouble to get my event listener to work with socket.io. I can log my click in frontend but it will never get logged in backend. Someone that can point me in the right direction?
Here is a part of the frontend code. The button click gets logged in frontend. I´m trying to pass a string to backend with no success.
This is the receiving part in the backend, no log output what so ever, not even the static text( Is clicked: )
This code runs on a raspi so i tail the syslog. The only thing that gets logged is the ws connection:
![image](https://user-images.githubusercontent.com/57908564/112713032-3302d780-8ed3-11eb-99a0-9024760c73f6.png)
I should really appreciate your help
Beta Was this translation helpful? Give feedback.
All reactions