[ENet-discuss] What about a custom packet pattern?

Sergio Martin smartin at freedomfactorystudios.com
Thu Apr 14 03:40:04 PDT 2011


Hi,

In order to meet our client custom network requirement, I need to send 
each UDP packet data as following:

[ size_of_game_data ] [ game_data ] [ voice_data ]


How difficult would be to modify ENet behaviour to meet that pattern?
I'm not sure how to deal with ENet's packet fragmentation.

I'm thinking of adding to ENetPacket struct two new variables:
enet_uint8 * voiceData;             /**< allocated voice data for packet */
size_t           voiceDataLength;  /**< length of voice data */

Change: enet_packet_create (const void * data, size_t dataLength, 
enet_uint32 flags)
To this: enet_packet_create(const void * data, size_t dataLength, const 
void * voiceData, size_t voiceDataLength, enet_uint32 flags)

And then modify the rest of ENet to support it.


Is this the correct approach?


Best Regards,
Sergio Martin.



More information about the ENet-discuss mailing list