[julia-users] help with integrating websockets and protobuf

2016-07-25 Thread Jon Norberg
Anyone have any experiences with protobuf/web Sockets?



[julia-users] help with integrating websockets and protobuf

2016-07-22 Thread Jon Norberg
just to check that there is no problem in the formats, the following does send 
a ljulia-protobuf formatted message to the html-client but somewhat 
indirectly

msg = read(client)
iob = PipeBuffer();
write(iob,msg)
test = readproto(iob,com())
println("got MESSAGE: $test.id")  #i.e. works!
writeproto(iob,com(id=[1],val=[0.2]))
msg=read(iob)
write(client,msg)#the new value 
turns up at the client, so no issues with the formatting, just to get the web 
socket to talk via readproto and writeproto

[julia-users] help with integrating websockets and protobuf

2016-07-22 Thread Jon Norberg
Dear julia community. 

I can't figure out whats wrong here. I have a web socket implementation that 
works just fine without using protobuf on the julsa/websocket side (in fact, 
the html-client does send a protobuf array which just gets sent back without 
unpacking and packing on the julia web socket side, i.e. echo server.

the relevant lines in the web socket server are:

msg = read(client) # This receives messages
write(client,msg)   # This sends it back

I can then unpack it on the html-client side again just fine.

I have defined a protobuf type as 

type com
id::Array{Int32,1}
val::Array{Float32,1}
com(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || 
ProtoBuf._protobuild(o, kwargs); o)
end #type com
hash(v::com) = ProtoBuf.protohash(v)
isequal(v1::com, v2::com) = ProtoBuf.protoisequal(v1, v2)
==(v1::com, v2::com) = ProtoBuf.protoeq(v1, v2)

and the following works as it should:

iob = PipeBuffer();
writeproto(iob,com(id=[1],val=[0.2]))
msg = readproto(iob,com())
println(msg)

But when I change the relevant lines in the web socket code on the server side 
to:

msg = readproto(client.socket,com())
writeproto(client.socket,com(id=[1],val=[0.2]))

it does not work.

 I did figure out that client is a composite type and that client.socket is of 
type TCPSocket which I assume is the right variable to pass to the protobuf 
functions.

Can anyone spot what I am missing? 

the protofile is:

message com {
  repeated int32 id = 1;
  repeated float val =2;
}