From: Rich M. <jp...@gm...> - 2011-05-21 16:47:01
|
On 05/21/2011 10:18 AM, Abqori Aula wrote: > Hi all, > > I'm having this issue regarding data type of opaqueproxy. > From doc, I understand that it is uint8_t, which IMHO is limiting the > type of data to be transfered. > > For example: > player_opaque_data_t opdata; > opdata.data_count=2; > opdata.data = new uint8_t[2]; > opdata.data[0]='F'; > opdata.data[1]='1'; > > What if I want to send a double type position x from GetPos() as data > instead? > example: > double posx = pp.GetXPos(); > opdata.data[1] = posx; > > it will show something like this: > SENT DATA: F143! > SENT count: 6 > The type is only uint8_t because each uint8 is one byte, which makes packing larger types and structs into it a lot easer. The examples in examples/plugins/opaquedriver/ outline how to do what you're trying to do. opaquedriver.cc contains a driver which packs a user-defined structure (defined in sharedstruct.h) into the opaque proxy. There's also opaque.c, which uses the playerc client library to subscribe to the example driver and unpack the structure from the opaque message. You can use the same kind of casting to send any datatypes you want. Rich |