@Override
 public void onReceive(Object message) throws Exception {
   if (message instanceof Tcp.Received) {
     ByteString data = ((Tcp.Received) message).data();
     connection.tell(TcpMessage.write(data, new Ack()), getSelf());
   } else if (message instanceof Ack) {
     connection.tell(TcpMessage.resumeReading(), getSelf());
   }
 }
Exemple #2
0
  @Override
  public void onReceive(Object msg) throws Exception {
    System.out.println("Handler received:" + msg);

    if (msg instanceof Received) {
      final ByteString data = ((Received) msg).data();
      getSender().tell(TcpMessage.write(data), getSelf());
    } else if (msg instanceof ConnectionClosed) {
      getContext().stop(getSelf());
    }
  }