@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());
        }
    }