Beispiel #1
0
        public void Encode(AvenueMessage message, IBufferWriter writer)
        {
            writer.WriteByte((byte)message.Flag);
            writer.WriteByte((byte)message.HeadLength);
            writer.WriteByte((byte)message.Version);
            writer.WriteByte(0x0F);

            writer.WriteInt(message.Length);
            writer.WriteInt(message.ServiceId);
            writer.WriteInt(message.MsgId);
            writer.WriteInt(message.Sequence);

            writer.WriteByte(0);
            writer.WriteByte((byte)message.MustReach);
            writer.WriteByte((byte)message.Format);
            writer.WriteByte((byte)message.Encoding);


            writer.WriteInt(0);

            writer.WriteBytes(AvenueConstans.EMPTY_SIGNATURE);

            if (message.XHead != null)
            {
                writer.WriteBytes(message.XHead);
            }

            if (message.Body != null)
            {
                writer.WriteBytes(message.Body);
            }
        }
 public override void SerializeMessage(ErrorMessage message, int protocolVersion, NetworkPeerContext peerContext,
                                       IBufferWriter <byte> output)
 {
     output.WriteBytes(message.ChannelId);
     output.WriteUShort(message.Len, true);
     output.WriteBytes(message.Data);
 }
 public override void SerializeMessage(PingMessage message, int protocolVersion, NetworkPeerContext peerContext,
                                       IBufferWriter <byte> output)
 {
     output.WriteUShort(message.NumPongBytes, true);
     output.WriteUShort(message.BytesLen, true);
     output.WriteBytes(message.Ignored);
 }
Beispiel #4
0
        public void Pack(IBufferWriter writer, AmpMessage message)
        {
            writer.WriteByte(message.Version);
            writer.WriteInt(message.Length);
            writer.WriteInt(message.Sequence);
            writer.WriteByte((byte)message.InvokeMessageType);

            if (message.Version == 0)
            {
                writer.WriteUShort((ushort)message.ServiceId);
            }
            else
            {
                writer.WriteInt(message.ServiceId);
            }


            writer.WriteUShort(message.MessageId);

            writer.WriteInt(message.Code);

            if (message.Version == 1)
            {
                writer.WriteByte(_serializer.CodecType);
            }

            if (message.Data != null)
            {
                writer.WriteBytes(message.Data);
            }
        }
Beispiel #5
0
 public void Encode(AmpMessage message, IBufferWriter writer)
 {
     writer.WriteByte(message.Version);
     writer.WriteInt(message.Length);
     writer.WriteInt(message.Sequence);
     writer.WriteByte((byte)message.InvokeMessageType);
     writer.WriteUShort(message.ServiceId);
     writer.WriteUShort(message.MessageId);
     if (message.Data != null)
     {
         writer.WriteBytes(message.Data);
     }
 }
 private void WriteProtocol(JoinGroupRequest.Protocol message, IBufferWriter <byte> output)
 {
     output.WriteString(message.Name);
     output.WriteBytes(message.Metadata);
 }
Beispiel #7
0
        public void Pack(IBufferWriter writer, CommandLineMessage message)
        {
            string content = $"{message.Command}{SPLITER}{string.Join(SPLITER, message.Parameters)}";

            writer.WriteBytes(Encoding.UTF8.GetBytes(content));
        }
 private void WriteAssignment(SyncGroupRequest.Assignment message, IBufferWriter <byte> output)
 {
     output.WriteString(message.MemberId);
     output.WriteBytes(message.AssignmentData);
 }