[enet-cvs] CVS: enet peer.c,1.16,1.17
Lee Salzman
enet at sferik.cubik.org
Sun Dec 14 18:19:55 PST 2003
Update of /home/enet/cvsroot/enet
In directory sferik:/tmp/cvs-serv20304
Modified Files:
peer.c
Log Message:
new feature
Index: peer.c
===================================================================
RCS file: /home/enet/cvsroot/enet/peer.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- peer.c 2003/12/15 02:13:07 1.16
+++ peer.c 2003/12/15 02:19:53 1.17
@@ -391,11 +391,42 @@
enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0);
}
+/** Force an immediate disconnection from a peer.
+ @param peer peer to disconnect
+ @remarks No ENET_EVENT_DISCONNECT event will be generated. The foreign peer is not
+ guarenteed to receive the disconnect notification, and is reset immediately upon
+ return from this function.
+*/
+void
+enet_peer_disconnect_now (ENetPeer * peer)
+{
+ ENetProtocol command;
+
+ if (peer -> state != ENET_PEER_STATE_DISCONNECTED)
+ return;
+
+ if (peer -> state != ENET_PEER_STATE_ZOMBIE &&
+ peer -> state != ENET_PEER_STATE_DISCONNECTING)
+ {
+ enet_peer_reset_queues (peer);
+
+ command.header.command = ENET_PROTOCOL_COMMAND_DISCONNECT;
+ command.header.channelID = 0xFF;
+ command.header.flags = 0;
+ command.header.commandLength = sizeof (ENetProtocolDisconnect);
+
+ enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0);
+
+ enet_host_flush (peer -> host);
+ }
+
+ enet_peer_reset (peer);
+}
+
/** Request a disconnection from a peer.
@param peer peer to request a disconnection
@remarks An ENET_EVENT_DISCONNECT event will be generated by enet_host_service()
- once the disconnection is complete. Any packets that arrive until the disconnection
- completes will still be received as if peer were still connected.
+ once the disconnection is complete.
*/
void
enet_peer_disconnect (ENetPeer * peer)
More information about the enet-cvs
mailing list