ReadMessage() public method

Reads an embedded message field value from the stream.
public ReadMessage ( IMessage builder ) : void
builder IMessage
return void
Beispiel #1
0
        public void MergeFrom(pb.CodedInputStream input)
        {
    #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
            input.ReadRawMessage(this);
    #else
            uint tag;
            while ((tag = input.ReadTag()) != 0)
            {
                switch (tag)
                {
                default:
                    _unknownFields = pb.UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
                    break;

                case 10: {
                    ClientId = input.ReadString();
                    break;
                }

                case 18: {
                    MessageId = input.ReadString();
                    break;
                }

                case 24: {
                    Type = (MessageType)input.ReadEnum();
                    break;
                }

                case 34: {
                    if (time_ == null)
                    {
                        Time = new global.Google.Protobuf.WellKnownTypes.Timestamp();
                    }
                    input.ReadMessage(Time);
                    break;
                }

                case 40: {
                    Status = (MessageStatus)input.ReadEnum();
                    break;
                }

                case 50: {
                    Payload = input.ReadBytes();
                    break;
                }

                case 56: {
                    Response = (ResponseType)input.ReadEnum();
                    break;
                }
                }
            }
    #endif
        }
Beispiel #2
0
            internal void Main()
            {
                client = new TcpClient ();
                client.Connect (address, port);
                stream = client.GetStream ();
                stream.Write (Encoder.streamHelloMessage, 0, Encoder.streamHelloMessage.Length);
                stream.Write (clientIdentifier, 0, clientIdentifier.Length);
                var recvOkMessage = new byte [Encoder.okMessage.Length];
                stream.Read (recvOkMessage, 0, Encoder.okMessage.Length);
                if (recvOkMessage.Equals (Encoder.okMessage))
                    throw new Exception ("Invalid hello message received from stream server. " +
                    "Got " + Encoder.ToHexString (recvOkMessage));
                this.codedStream = new CodedInputStream (stream);

                try {
                    while (true) {
                        var message = new StreamMessage ();
                        codedStream.ReadMessage (message);
                        foreach (var response in message.Responses)
                            manager.Update (response.Id, response.Response);
                    }
                } catch (IOException) {
                    // Exit when the connection closes
                }
            }