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

Get new client ID at every refresh :( #1417

Open
S0004152598 opened this issue Jun 12, 2024 · 1 comment
Open

Get new client ID at every refresh :( #1417

S0004152598 opened this issue Jun 12, 2024 · 1 comment

Comments

@S0004152598
Copy link

Hi,
I have a litle problem whith you nice Websocket library. After the site refresh the client get a new connection ID. I need to select the clients by IP address. So I need to loop the clients but i could not, because I don't know the correct IDs. First connection ID is 1 but after a refresh the 1th ID dead and the new ID is the 2. and so on.
I don't want to loop on ID-s if I can get the connected cliens id-s from the class via a new public method or any other solution would be more the nice for me. if I could figure out the all connected clients ID-s. :)
th

@Belleson
Copy link

Try assigning a client ID in the client and sending it to the server to store in an array. I'm doing this in a websocket app with

function onLoad(evt) {
clientID = Date.now(); // Should be unique for each client
initWebSocket();
initElements();
initListeners();
}

and then having the server request clientID, where the client responds with

	websocket.send(JSON.stringify({ client: clientID}));

Hopefully this is also possible without websocket.

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