4 ms·
I'm not sure what your snippet is demonstrating, but it's not demonstrating message_id matchup. The client stores its own message_id -> callback mapping, it ha
by always_good 10y ago
I'm not sure what your snippet is demonstrating, but it's not demonstrating message_id matchup.
The client stores its own message_id -> callback mapping, it has to send some sort of reply id for the server or agree on some other mechanism, and it's not something you want to have to build on every project, just like exponential reconnect backaway.
And I'm not sure why you'd want to use the native WebSocket API by itself except on toy apps.
- josephg 10y agoYou're talking about a light layer on top of websockets to implement a request/response protocol. This can be done pretty trivially on top of websockets in dozens of ways, though if what you want is request/response you should consider using HTTP directly. You never have to "build it again for every project" if you put your code in npm. But I guarantee you there are dozens of libraries like this in npm already. (Just like there are dozens of libraries to do exponential reconnect backoff.) The right approach is to build / use light layers on top of websockets to solve these problems. Socket.io is the wrong solution. Its the wrong solution for every problem.