Beispiel #1
0
        public KeyValueMessage Receive(Socket socket, Encoding encoding)
        {
            var keyValueMessage = new KeyValueMessage(string.Empty, 0);

            for (int frameNumber = 0; frameNumber < KeyValueMessageFrames; frameNumber++)
            {
                var data = socket.Recv();
                if (data == null)
                {
                    keyValueMessage = null;
                    break;
                }

                var setter = FrameReceiveMap[frameNumber];
                setter(keyValueMessage, data, encoding);

                bool recvMore = frameNumber < KeyValueMessageFrames - 1 ? true : false;
                if (socket.RcvMore != recvMore)
                {
                    keyValueMessage = null;
                    break;
                }
            }

            return(keyValueMessage);
        }
Beispiel #2
0
        public KeyValueMessage Duplicate(KeyValueMessage message)
        {
            var keyValueMessage = new KeyValueMessage(Key, Sequence)
            {
                UUID = UUID,
            };

            Body.CopyTo(keyValueMessage.Body, 0);
            foreach (var property in Properties)
            {
                keyValueMessage.Properties.Add(property.Key, property.Value);
            }
            return(keyValueMessage);
        }