proto file:
package nemesis;

option java_package = "IQFeedServer.protobuf";
option java_outer_classname = "Protos";

option optimize_for = SPEED;

message V3DDelta {
   optional int32 bid = 1;
   optional int32 bidSize = 2;
   optional int32 ask = 3;
   optional int32 askSize = 4;
}

message Request {
   optional int32 type = 1;
   optional string request = 2;
}

message Response {
   optional int32 type = 1;
   optional string response = 2;
   repeated V3DDelta v3dDelta = 3;
}


protobuf-net classes:
[ProtoContract]
public class V3DDelta {
   [ProtoMember(1)]
   public double bid { get; set; }
   [ProtoMember(2)]
   public int bidSize { get; set; }
   [ProtoMember(3)]
   public double ask { get; set; }
   [ProtoMember(4)]
   public int askSize { get; set; }
}

[ProtoContract]
public class Request {
   [ProtoMember(1)]
   public int Type { get; set; }
   [ProtoMember(2)]
   public string Rq { get; set; }
}

[ProtoContract]
public class Response {
   [ProtoMember(1)]
   public int Type { get; set; }
   [ProtoMember(2)]
   public string Rsp { get; set; }
   [ProtoMember(3)]
   public List<V3DDelta> v3dDelta { get; set; }
   public Response() {
       v3dDelta = new List<V3DDelta>();
   }
}

When i'm sending message with v3dDeltas (doesn't matter 1 or more) i've got 
this:
 Invalid wire-type; this usually means you have over-written a file without 
truncating or setting the length; see 
http://stackoverflow.com/q/2152978/23354

The message is:
9 8 5 26 5 8 233 98 16 1
and is exactly the same on the other side (there's no other bytes in 
buffer). I'm reading it that way:
Response rsp = Serializer.DeserializeWithLengthPrefix<Response>(rcvstream, 
PrefixStyle.Base128);
(it is encoded using writeDelimitedTo on the java side).

It is right to use List for repeated fields? I tried use array (V3DDelta[]) 
but exception is the same. When there was no  v3dDelta field everything 
works great. I'm missing something?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/protobuf/-/jfYetWUvXiAJ.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to