public override Task WriteAsync(IChannelHandlerContext context, object message)
 {
     if (message is int)
     {
         State = State.WriteMessages((int) message);
     }
     return base.WriteAsync(context, message);
 }
        public override void ChannelRead(IChannelHandlerContext context, object message)
        {
            if (message is int)
            {
                var i = (int) message;
                State = State.ReceiveMessages(i);

                // echo the reply back to the client
                context.WriteAndFlushAsync(i);
            }
        }
 public override void ChannelInactive(IChannelHandlerContext context)
 {
     State = State.RemoveLocalChannel(context.Channel).RemoveClient((IPEndPoint) context.Channel.RemoteAddress);
 }
 public TcpServerSocketStateHandler(ITcpServerSocketModel state)
 {
     State = state;
 }