[ENet-discuss] Server disconnecting all clients - SOLVED

Ruud van Gaal ruud at racer.nl
Thu Nov 19 10:12:34 PST 2009


Never mind my previous question on server disconnects. The packets came in.
The line:
 
    while(enet_host_service(host,&event,1000)>0)

was the problem: the client was sending out a bunch of packets and it seemed
the polling wasn't fast enough to catch the disconnect in time (as if
enet_host_service() always took 1000 milliseconds, even if an event was
present, hm).
Now I'm using a timeout value of 0, getting faster reads and seeing the
client's disconnect. It all works. :)
 
Cheers,
Ruud
 


  _____  

Van: Ruud van Gaal [mailto:ruud at racer.nl] 
Verzonden: Thursday, November 19, 2009 18:28
Aan: 'Discussion of the ENet library'
Onderwerp: Server disconnecting all clients


Hi,
 
I have a problem where my clients don't get told when the server
disconnects.
I do this in my C++ wrapper:
 
  for(i=0;clients;i++)
  {
    // Disconnect client
    ENetPeer *peer=client[i].peer;

    // Start disconnect procedure
    enet_peer_disconnect(peer,0);

    // Wait a while for the disconnect to succeed
    ENetEvent event;
    while(enet_host_service(host,&event,1000)>0)
    {
      switch (event.type)
      {
        case ENET_EVENT_TYPE_RECEIVE: qdbg("pkt\n"); enet_packet_destroy
(event.packet); break;
        case ENET_EVENT_TYPE_DISCONNECT: qdbg("QNServer:Disconnect()
succeeded."); ok=true; break;
        default: qdbg("ENet unknown event during QNServer:Disconnect()");
break;
      }
    }

This calls enet_peer_disconnect() for all peers that are connected to the
server host. However, the clients don't seem to get the DISCONNECT events.
Must I make some kind of special packet myself to have the clients
disconnect themselves? Or is there a way that the server will tell all the
clients that it's disconnecting (gracefully)?
I left out error checking here (peer is not 0 for example).
 
Thanks,
Ruud
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20091119/677571fb/attachment.htm>


More information about the ENet-discuss mailing list