You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An open event is only necessary on the client side, as it informs the client that the server has established the connection and is ready to communicate.
In this example, you are in control of the server side of the connection and have received a request from a client to use WebSockets. The moment your application calls server.accept() your server websocket is ready to send messages, so there's no point in dispatching an "open" event -- the connection is already ready from the servers POV.
Basically, if you're a client, you have to "wait" for the server to say it's ready before you send any messages with your websocket. If you're a server, you have nothing to wait for (websocket comms are bi-directional), so you can start sending messages immediately.
The websocket server doesn't emit the open event ever.
So the following code:
Never runs.
Even though the close and message events do get emitted.
The text was updated successfully, but these errors were encountered: