[ENet-discuss] Identifying clients

shinyclaw shinyclaw at op.pl
Sat Mar 3 10:20:41 UTC 2018


Thanks again Ruud, that was very helpful.
 
W dniu 2018-03-03 09:53:42 użytkownik Ruud van Gaal <ruud at racer.nl> napisał:
Hi,
 
That is correct, it's on the client side. Let me answer this a little less quickly: in my client class I have:
 
if(event.type==ENET_EVENT_TYPE_CONNECT)
...
        // Get a client ID from ENet internals
        id=event.peer->outgoingPeerID+QNServer::BASE_ID;
 
(I actually use an offset to avoid using the 'id' as an offset in array; they should be id's, not indices if you get a little more complex)
 
In the server class indeed I use 'incomingPeerID' to store information about the client:
 
if(event.type==ENET_EVENT_TYPE_CONNECT)
...
      // Add client to this server
      Client *c=&client[clients-1];
      c->id=event.peer->incomingPeerID+QNServer::BASE_ID;
 
Cheers,
Ruud
 
On Fri, Mar 2, 2018 at 5:27 PM, shinyclaw <shinyclaw at op.pl> wrote:
Thanks Ruud, I assume that this is the case on the client side? On the server side, it should be event.peer->incomingPeerID?
 
W dniu 2018-03-02 16:29:36 użytkownik Ruud van Gaal <ruud at racer.nl> napisał:
I use event.peer->outgoingPeerID.
 
Ruud
On Fri, Mar 2, 2018 at 2:23 PM, shinyclaw <shinyclaw at op.pl> wrote:
Hi all, I'm trying to write a simple client-server game using ENet. I have a small problem with client's identification using enet_host_service() method. Each new client that connects to the server should have a unique netID, so later the server knows who is talking to him. But how can I achieve that? On the server, when receiving ENET_EVENT_TYPE_CONNECT event should I assign event.peer to newly created GameObject? Or use event.peer->outgoingPeerID or incomingPeerID? Or peer.sessionID? Or something else? Thanks for any help!
_______________________________________________
ENet-discuss mailing list
ENet-discuss at cubik.org
http://lists.cubik.org/mailman/listinfo/enet-discuss
 
_______________________________________________
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/20180303/a99b83cb/attachment-0001.html>


More information about the ENet-discuss mailing list