예제 #1
0
 public override void WriteMessageBegin(TMessage message)
 {
     if (strictWrite_)
     {
         uint version = VERSION_1 | (uint)(message.Type);
         WriteI32((int)version);
         WriteString(message.Name);
         WriteI32(message.SeqID);
     }
     else
     {
         WriteString(message.Name);
         WriteByte((byte)message.Type);
         WriteI32(message.SeqID);
     }
 }
예제 #2
0
		public override void WriteMessageBegin(TMessage message)
		{
			if (strictWrite_)
			{
				uint version = VERSION_1 | (uint) (message.Type);
				WriteI32((int) version);
				WriteString(message.Name);
				WriteI32(message.SeqID);
			}
			else
			{
				WriteString(message.Name);
				WriteByte((byte) message.Type);
				WriteI32(message.SeqID);
			}
		}
예제 #3
0
		public override TMessage ReadMessageBegin()
		{
			var message = new TMessage();
			int size = ReadI32();
			if (size < 0)
			{
				uint version = (uint) size & VERSION_MASK;
				if (version != VERSION_1)
				{
					throw new TProtocolException(TProtocolException.BAD_VERSION, "Bad version in ReadMessageBegin: " + version);
				}
				message.Type = (TMessageType) (size & 0x000000ff);
				message.Name = ReadString();
				message.SeqID = ReadI32();
			}
			else
			{
				if (strictRead_)
				{
					throw new TProtocolException(TProtocolException.BAD_VERSION, "Missing version in readMessageBegin, old client?");
				}
				message.Name = ReadStringBody(size);
				message.Type = (TMessageType) ReadByte();
				message.SeqID = ReadI32();
			}
			return message;
		}
예제 #4
0
		public abstract void WriteMessageBegin(TMessage message);
예제 #5
0
 public abstract void WriteMessageBegin(TMessage message);
예제 #6
0
		public override TMessage ReadMessageBegin()
		{
			var message = new TMessage();
			ReadJSONArrayStart();
			if (ReadJSONInteger() != VERSION)
			{
				throw new TProtocolException(TProtocolException.BAD_VERSION,
				                             "Message contained bad version.");
			}

			message.Name = utf8Encoding.GetString(ReadJSONString(false));
			message.Type = (TMessageType) ReadJSONInteger();
			message.SeqID = (int) ReadJSONInteger();
			return message;
		}
예제 #7
0
		public override void WriteMessageBegin(TMessage message)
		{
			WriteJSONArrayStart();
			WriteJSONInteger(VERSION);

			byte[] b = utf8Encoding.GetBytes(message.Name);
			WriteJSONString(b);

			WriteJSONInteger((long) message.Type);
			WriteJSONInteger(message.SeqID);
		}
 /**
 * Write a message header to the wire. Compact Protocol messages contain the
 * protocol version so we can migrate forwards in the future if need be.
 */
 public override void WriteMessageBegin(TMessage message)
 {
     WriteByteDirect(PROTOCOL_ID);
     WriteByteDirect((byte)((VERSION & VERSION_MASK) | ((((uint)message.Type) << TYPE_SHIFT_AMOUNT) & TYPE_MASK)));
     WriteVarint32((uint)message.SeqID);
     WriteString(message.Name);
 }