public XyzMessage[] Decode()
        {
            List <XyzMessage> messages = new List <XyzMessage>();
            MemoryStream      stream   = new MemoryStream(message);

            while (stream.Position < stream.Length)
            {
                byte[] lenBytes = new byte[4];
                stream.Read(lenBytes, 0, lenBytes.Length);
                int length = BitConverter.ToInt32(lenBytes, 0);

                byte[] typeBytes = new byte[1];
                stream.Read(typeBytes, 0, typeBytes.Length);
                int type = (int)typeBytes[0];

                byte[] messageBytes = new byte[length];
                stream.Read(messageBytes, 0, messageBytes.Length);

                XyzMessage message = new XyzMessage(messageBytes, type);

                messages.Add(message);
            }

            return(messages.ToArray());
        }
Beispiel #2
0
 public void SendSync(IPEndPoint sendTo, XyzMessage message, int type = 0)
 {
     byte[] payload = new XyzMessageBuilder().Add(message).ToArray();
     this.SendSync(sendTo, payload, type);
 }
Beispiel #3
0
 public void Send(XyzMessage message, int type = 0)
 {
     byte[] payload = new XyzMessageBuilder().Add(message).ToArray();
     this.Send(payload, type);
 }
Beispiel #4
0
 public XyzMessageBuilder Add(XyzMessage message)
 {
     Add(message.Bytes, message.Type);
     return(this);
 }