Beispiel #1
0
        public MessageSendCallBack SendRequest(SocketRequestMessage request)
        {
            this.requestMessage = Unpooled.Buffer(MessageSendSettings.Size);
            var callBack = new MessageSendCallBack(request);

            this.callBackActions.TryAdd(request.MessageId, callBack);
            this.requestMessage.WriteBytes(this.serializer.Serialize(request));
            this.channelContext.WriteAndFlushAsync(this.requestMessage);

            return(callBack);
        }
Beispiel #2
0
        public override void ChannelRead(IChannelHandlerContext context, object message)
        {
            if (message is IByteBuffer byteBuffer)
            {
                var response = (SocketResponseMessage)this.serializer.Deserialize(byteBuffer.Array);

                MessageSendCallBack callBack = this.callBackActions[response.MessageId];
                callBack.Over(new SocketResponseMessage());
                Console.WriteLine("Received from server: " + response.MessageId);
            }
        }