From the course: WebSocket Programming with Java EE

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

WebSocket front end and back end

WebSocket front end and back end

From the course: WebSocket Programming with Java EE

Start my 1-month free trial

WebSocket front end and back end

- [Narrator] As previously discussed, the WebSocket connection is initiated by the client. Which sends a HTTP upgrade request to the server. The server responds with a 101 Switching Protocol status code to confirm that the switching has occurred. Then after the handshake, the client and the server can send messages to each other at will until either side sends a close notification or there is a connection error. From a coding perspective what does this look like? Well, if the client is a browser, we initiate the connection by simply creating a new WebSocket and passing the URI to the end point. The server application receives the request on the specified URI and creates a session. And this session remains open for the duration of the connection. Both sides create eventlessness for messages and can start to exchange messages. Additional listeners are set up for error and close events. If the WebSocket client is a browser, you need to ensure that you check that the browser is WebSocket…

Contents