Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #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);
        }
Beispiel #4
0
 public static RawMessageHeader From(RawMessageHeader copy) => From(copy._nodeId, copy._type, copy._length);
Beispiel #5
0
        public static RawMessageHeader From(Stream buffer)
        {
            var header = new RawMessageHeader();

            return(header.Read(buffer));
        }
Beispiel #6
0
 public void Header(RawMessageHeader header) => _header = header;
Beispiel #7
0
 public static RawMessage From(int nodeId, int type, int length) => new RawMessage(RawMessageHeader.From(nodeId, type, length), length);
Beispiel #8
0
 public RawMessage(RawMessage copy) : this(copy.Length)
 {
     Append(copy._bytes, 0, copy.Length);
     Header(RawMessageHeader.From(copy._header));
 }
Beispiel #9
0
 public RawMessage(byte[] bytes)
 {
     _bytes  = bytes;
     _header = new RawMessageHeader();
     _index  = bytes.Length;
 }
Beispiel #10
0
 public RawMessage(RawMessageHeader header, long maxMessageSize)
 {
     _bytes  = new byte[maxMessageSize];
     _header = header;
     _index  = 0;
 }