[ENet-discuss] Problem partailly solved

Nuno Silva little.coding.fox at gmail.com
Mon Feb 28 03:47:03 PST 2011


The data that peer->data has is application-specific for your active
application. What this means is, you can't share it since there's no way for
ENet to know e.g., how many bytes you set, and it isn't transmitted by ENet.
It's merely a way to provide user data to the peer while you're working with
peers on ENet (this way you dont have to use a secondary mechanism to find a
peer by ENetPeer *).

So after you get connected, you should send a packet specifying the player's
name (best to send a Reliable packet in this case) or something similar.

On Mon, Feb 28, 2011 at 11:32 AM, Alexaroth <alex_prislopeanu at yahoo.com>wrote:

> Well I kinda understand how things work... the thing is this
>
> I have some client code:
>
> peer = enet_host_connect (client, & address, 2, 0);
> name =  player.getname();    //this returns a string from inside a class
> member
> peer->data = (void*)name.c_str();  I am making the peer data the name of
> the player
>
>
> On the server end:
>
> ENetPeer *peer2[2];
>
> while (enet_host_service (server, & event, 100) > 0)
>     {   switch (event.type)
>         {
>         case ENET_EVENT_TYPE_CONNECT:
>
>             peer2[1] = event.peer;
>             textprintf_ex(screen, font, 10, 200, white,-1,"%s is client
> !",peer2[1]->data);   this is allegro, it just outputs the %s is client on
> screen
>             name=(char*)peer->data;
>    ....
>
>
> The problem is that this crashes when it tries to output the peer2[1]->data
> . When debugging I checked to see if the peer2[1].data changes to whatever
> the client has set it but its just 0x000000 .
> So my question... shouldn't event.peer have the data that the client has
> set ?
>
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20110228/c45c9c95/attachment.html>


More information about the ENet-discuss mailing list