HTML5 Web APIs

Exercise: WebSockets

The backend chat service provides WebSocket connections at the URL wss://chat.distsys.ch/ws on which new chat messages can be exchanged.
  • In the JavaScript chat.js remove the polling of the chat messages.
  • Create a web socket connection to the chat service and send the authentication token as first message.
  • Install an onmessage event handler on the web socket that renders the received chat message.
  • In the postMessage function send the new chat text using the web socket.