public static RawMessage ReadFromWithoutHeader(Stream buffer)
        {
            var header  = RawMessageHeader.From(0, 0, buffer.Length);
            var message = new RawMessage(header, header.Length);

            message.PutRemaining(buffer);
            return(message);
        }
        public static RawMessage From(int nodeId, int type, string textMessage)
        {
            var textBytes = Converters.TextToBytes(textMessage);
            var header    = RawMessageHeader.From(nodeId, type, textBytes.Length);
            var message   = new RawMessage(header, textBytes.Length);

            message.Append(textBytes, 0, textBytes.Length);
            return(message);
        }
Exemple #3
0
        public static RawMessage ToRawMessage(this short sendingNodeId, Stream buffer)
        {
            buffer.Flip();
            var message = new RawMessage(buffer.Length);

            message.Put(buffer, false);
            buffer.SetLength(0); // clear

            var header = new RawMessageHeader(sendingNodeId, (short)0, (int)message.Length);

            message.Header(header);
            return(message);
        }
 public void Header(RawMessageHeader header) => _header = header;
 public static RawMessage From(int nodeId, int type, int length) => new RawMessage(RawMessageHeader.From(nodeId, type, length), length);
 public RawMessage(RawMessage copy) : this(copy.Length)
 {
     Append(copy._bytes, 0, copy.Length);
     Header(RawMessageHeader.From(copy._header));
 }
 public RawMessage(byte[] bytes)
 {
     _bytes  = bytes;
     _header = new RawMessageHeader();
     _index  = bytes.Length;
 }
 public RawMessage(RawMessageHeader header, long maxMessageSize)
 {
     _bytes  = new byte[maxMessageSize];
     _header = header;
     _index  = 0;
 }
Exemple #9
0
 public static RawMessageHeader From(RawMessageHeader copy) => From(copy._nodeId, copy._type, copy._length);
Exemple #10
0
        public static RawMessageHeader From(Stream buffer)
        {
            var header = new RawMessageHeader();

            return(header.Read(buffer));
        }