Repository navigation
|
Hi Alex, I’m having an issue to declare a local variable foo (see below) which is only visible inside the socket connection handlers (open, message, close). The variable foo can’t be declared globally, otherwise it will be visible for all the connections (total mess). I checked the examples but couldn’t find a solution to my problem. |
Answered by
hst-m
Oct 29, 2020
Replies: 2 comments
|
You've got an extra set of open:ws=>{
ws.foo=true
},
message:(ws,message,isBinary)=>{
console.log(ws.foo)
} |
0 replies
|
Thanks a mill. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You've got an extra set of
})at the end that needs to be removed, andopenevent does not havereqso you need to remove that, and if you want to share something acrossopenandmessageevents you should put it in thewsobject