<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16890" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=296110618-19112009><FONT face=Arial
color=#0000ff size=2>Never mind my previous question on server disconnects. The
packets came in. The line:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=296110618-19112009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=296110618-19112009><FONT face=Arial
size=2>
while(enet_host_service(host,&event,1000)>0)</FONT><BR></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=296110618-19112009><FONT face=Arial
color=#0000ff size=2>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).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=296110618-19112009><FONT face=Arial
color=#0000ff size=2>Now I'm using a timeout value of 0, getting faster reads
and seeing the client's disconnect. It all works. :)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=296110618-19112009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=296110618-19112009><FONT face=Arial
color=#0000ff size=2>Cheers,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=296110618-19112009><FONT face=Arial
color=#0000ff size=2>Ruud</FONT></DIV></SPAN>
<DIV dir=ltr align=left><SPAN class=296110618-19112009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV><FONT face=Arial color=#0000ff
size=2></FONT><FONT face=Arial color=#0000ff size=2></FONT><BR>
<DIV class=OutlookMessageHeader lang=nl dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>Van:</B> Ruud van Gaal [mailto:ruud@racer.nl]
<BR><B>Verzonden:</B> Thursday, November 19, 2009 18:28<BR><B>Aan:</B>
'Discussion of the ENet library'<BR><B>Onderwerp:</B> Server disconnecting all
clients<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=984092417-19112009>Hi,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=984092417-19112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=984092417-19112009>I have a problem
where my clients don't get told when the server disconnects.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=984092417-19112009>I do this in my C++
wrapper:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=984092417-19112009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2> for(i=0;clients;i++)<BR>
{<BR> // Disconnect client<BR> ENetPeer
*peer=client[i].peer;<BR></FONT></DIV>
<DIV><FONT face=Arial size=2> // Start disconnect
procedure<BR> enet_peer_disconnect(peer,0);<BR></FONT></DIV>
<DIV><FONT face=Arial size=2> // Wait a while for the
disconnect to succeed<BR> ENetEvent
event;<BR>
while(enet_host_service(host,&event,1000)>0)<BR>
{<BR> switch
(event.type)<BR>
{<BR> case ENET_EVENT_TYPE_RECEIVE:
qdbg("pkt\n"); enet_packet_destroy (event.packet);
break;<BR> case
ENET_EVENT_TYPE_DISCONNECT: qdbg("QNServer:Disconnect() succeeded."); ok=true;
break;<BR> default: qdbg("ENet unknown
event during QNServer:Disconnect()"); break;<BR>
}<BR> }<BR></FONT></DIV>
<DIV><FONT size=+0><SPAN class=984092417-19112009><FONT face=Arial size=2>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)?</FONT></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=984092417-19112009>I left out error
checking here (peer is not 0 for example).</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=984092417-19112009></SPAN></FONT> </DIV>
<DIV><FONT size=+0><SPAN class=984092417-19112009></SPAN></FONT><FONT
size=+0><SPAN class=984092417-19112009><FONT face=Arial
size=2>Thanks,</FONT></SPAN></FONT></DIV>
<DIV><FONT size=+0><SPAN class=984092417-19112009><FONT face=Arial
size=2>Ruud</FONT></SPAN></FONT></DIV>
<DIV><FONT size=+0><SPAN class=984092417-19112009><FONT face=Arial
size=2></FONT></SPAN> </DIV></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>