-
Consider you have whatever uWebSocket code, details are not what matters. Let's assume you want to put all the websockets you get into one array and delete any whenever it closes. The first part is easy, you can even know what websocket you are currently working with (given you get drain() or message()) by checking for instance its ip, but what about close event? I can't get the websocket's ip in the function, which would be nice. Is there any way to recognise the websocket other way than by its address? The structure of uWebSocket doesn't allow something like: ws.onopen = function() {};
ws.onmessage = function() {}; which could solve this problem I'm having really easily. Working with IP is good enough too, just that in the close() function it cannot be gotten.
index.d.ts states the following as a comment to the
May not use WebSocket AFTER the event, and can't send anything. It mentions nothing about not being able to still access the WebSocket's IP. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You are handed the same very object in all events (by reference, not only by value). So from that you can achieve anything you want. |
Beta Was this translation helpful? Give feedback.
You are handed the same very object in all events (by reference, not only by value). So from that you can achieve anything you want.