@Override
 public void write(byte[] data) throws IOException {
   if (webSocket.isConnected()) {
     webSocket.send(data);
   }
 }
 @Override
 public void sendDone() {
   WebSocketHelper.sendData(socket, "done");
   if (socket.isConnected()) socket.close();
 }
 @Override
 public void write(int data) throws IOException {
   if (webSocket.isConnected()) {
     webSocket.send(String.valueOf(data));
   }
 }
 @Override
 public void sendError(String message) {
   if (socket.isConnected()) WebSocketHelper.sendError(socket, message);
 }