Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set variable on socket connection #3603

Closed
ughstudios opened this issue May 23, 2020 · 2 comments
Closed

Set variable on socket connection #3603

ughstudios opened this issue May 23, 2020 · 2 comments

Comments

@ughstudios
Copy link

Is it possible to set a variable on a socket connection to be permanently there?

For example:
io.on('connection', client => { client.lobby_id = "sadjasdhjkas"; });

I want client.id to be there until it disconnects obviously. Would this mean that the variable lobby_id will always be there for that client socket connection, and could i access it in any events?

@darrachequesne
Copy link
Member

Yes indeed. As long as you don't overwrite a property of the socket object (ref here), it should work.

@darrachequesne
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants