On Sun, Jan 17, 2010 at 02:54:10PM -0500, Alex Milstead wrote: > In that case, is there a solid way to extract that identifier? Or will > I need to do some I'm aware of sprintf calls, is it common practice to > simply "sprintf" the first integer of the received binary data into a > buffer and (effectively) switch-case on that buffer, then memcpy the > remaining data that follows? Or is there a better way of doing this?
What I do in my project is send google protocal buffer messages back and forth. To figure out which is which, each time I send I wrap them in another message that has two fields, a name and a blob where I serialize whatever the real message is. Using the built-in reflection of protocol buffers I can figure out what to call each message, and using some templates and maps I am able to make use of the protocol buffers builders on the receive side to build messages up as objects. From there its just a matter of dispatching to various event handlers. It took a bit of work to get functional, but now that it works it's pretty nice to just say send(whateverObject) and hook up some event handler for that type on the other end. It does feel rather heavy compared to what other people are suggesting about enums and structs too :) Eugene _______________________________________________ ENet-discuss mailing list [email protected] http://lists.cubik.org/mailman/listinfo/enet-discuss
