Beispiel #1
0
        private Message(byte[] bytes)
        {
            var bytesAsList = bytes.ToList();

            Type = (PeerCommandType)bytes[0];

            const int startHeadIndex = 1;
            var       endHeadIndex   = FindBytesIndex(bytes, END_HEAD_DELIMITER);
            var       endIndex       = FindBytesIndex(bytes, END_DELIMITER);
            var       startBodyIndex = endHeadIndex + END_HEAD_DELIMITER.Length;

            head = bytesAsList.GetRange(startHeadIndex, endHeadIndex - startHeadIndex).ToArray();
            body = bytesAsList.GetRange(startBodyIndex, endIndex - startBodyIndex).ToArray();
        }
Beispiel #2
0
 protected Message(Message message)
 {
     Type = message.Type;
     head = message.head;
     body = message.body;
 }
Beispiel #3
0
 public Message(PeerCommandType type)
 {
     Type = type;
     head = new byte[0];
     body = new byte[0];
 }