Replies: 1 comment
-
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 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. |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions