Replies: 2 comments 2 replies
-
You are mixing up two different types of clients. Do you want to use the simple client or the regular client? The simple client does not use event handlers nor callbacks. This hybrid approach that combines the two clients you are trying to use here is not a supported usage. So first of all, switch to the regular client ( |
Beta Was this translation helpful? Give feedback.
-
Thanks @miguelgrinberg , I implemented the suggested changes. I concluded that I don't need the callback since from the server I am emitting an event back to the client. So I am using an event handler per client instance. However, I am still seeing the event triggered just for one sid (presumably the last one handled): Updated code:
The output:
In a socketio-client per thread setup this works fine, so I am assuming there's something wrong with the client-side, and not something on the server-side. |
Beta Was this translation helpful? Give feedback.
-
Hi, I wanted to ask how registering callbacks to multiple socketio clients works. I have a code snippet where I'm initializing socketio clients in a loop and then emitting a call from each client to the server, whilst registering a callback. In the callback the sid returned is the same sid (presumably for the last client only). When I try the same with a client per thread it works, but for my purposes a client per thread is not feasible so I wanted to understand if this is some kind of known limitation. I saw this line in the docs: Callback functions can only be used when addressing an individual client. but it does not seem to apply to my case since I have a unique client per call. I am using latest version of the library.
Code snippet:
Output for the above:
Beta Was this translation helpful? Give feedback.
All reactions