public WebSocketTransport(Manager manager, ClientData clientData) {
    super(manager, clientData);

    webSocket = clientData.getSocket();

    webSocket.exceptionHandler(
        new Handler<Exception>() {
          public void handle(Exception e) {
            end("socket error " + ((e != null) ? e.getMessage() : ""));
          }
        });

    webSocket.closedHandler(
        new Handler<Void>() {
          public void handle(Void event) {
            end("socket end");
          }
        });

    webSocket.dataHandler(
        new Handler<Buffer>() {
          public void handle(Buffer buffer) {
            onMessage(parser.decodePacket(buffer.toString()));
          }
        });
  }
 @Override
 public void write(String encodedPacket) {
   log.debug(getName() + " writing " + encodedPacket);
   webSocket.writeTextFrame(encodedPacket);
 }
 /**
  * Closes the connection.
  *
  * @see "WebSocket.prototype.doClose"
  */
 @Override
 protected void doClose() {
   webSocket.close();
 }