// This websocket client runs in the browser and talks to the
// websocket server that's defined in server.js.

class Client {
  constructor() {
    this.ws = new WebSocket("ws://localhost:9090")

    this.ws.onmessage = function(event) {
      console.log("received: " + event.data)
    }
  }
}

module.exports = Client

@@ -151,143 +151,763 @@
 his.
-ws = new WebSocket(%22ws://localhost:9090%22)%0A%0A    this.ws.onmessage = function(event) %7B%0A      console.log(%22received: %22 + event.data)%0A    %7D
+makeSocket()%0A  %7D%0A%0A  makeSocket() %7B%0A    let url = %22ws://localhost:9090%22%0A    console.log(%60connecting to $%7Burl%7D%60)%0A%0A    // TODO: needs a more aggressive timeout%0A    this.ws = new WebSocket(url)%0A%0A    this.ws.onmessage = (event =%3E this.receive(event.data))%0A    this.ws.onerror = (event =%3E this.handleError())%0A    this.ws.onclose = (event =%3E this.handleClose())%0A  %7D%0A%0A  // When data is received from the server%0A  receive(data) %7B%0A    console.log(%22received: %22 + data)%0A  %7D%0A%0A  handleError() %7B%0A    console.log(%22socket error. closing dirty socket%22)%0A    this.ws.close()%0A  %7D%0A%0A  // Whenever the socket closes we just make a new one%0A  handleClose() %7B%0A    console.log(%22the socket closed%22)%0A    %0A    // Wait 2 seconds to reconnect%0A    setTimeout(() =%3E this.makeSocket(), 2000)
 %0A  %7D

make the client retry so we can reboot the server