code: function onMessage(message) {
      if (done) return
      if (message.type != "utf8") return sendConnectFailed(wsConn)
  
      try {
        message = JSON.parse(message.utf8Data)
      }
      catch(err) {
        return sendConnectFailed(wsConn)
      }
  
      var id  = message.id
  
      if (message.type != "request") return sendConnectFailed(wsConn)
      if (message.name != "connect") return sendConnectFailed(wsConn)
      if (message.to   != "server") return sendConnectFailed(wsConn)
  
      var body = message.body || {}
  
      if (!body.key) return sendConnectFailed(wsConn)
  
      var session = sessions.getSession(body.key)
      var channel = channels.createChannel(session, wsConn)
  
      message = {
        type: "response",
        name: "connect",
        from: "server",
        id:   message.id,
        body: null
      }
  
      wsConn.sendUTF(JSON.stringify(message))
      cleanUp()
    }
docs: -----------------------------------