Logo Search packages:      
Sourcecode: egoboo version File versions  Download package

void enet_peer_disconnect ( ENetPeer peer  ) 

Request a disconnection from a peer.

Parameters:
peer peer to request a disconnection
Remarks:
An ENET_EVENT_DISCONNECT event will be generated by enet_host_service() once the disconnection is complete.

Definition at line 430 of file peer.c.

References enet_host_flush(), and enet_peer_reset().

{
    ENetProtocol command;

    if (peer -> state == ENET_PEER_STATE_DISCONNECTING ||
        peer -> state == ENET_PEER_STATE_DISCONNECTED ||
        peer -> state == ENET_PEER_STATE_ZOMBIE)
      return;

    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);

    if (peer -> state == ENET_PEER_STATE_CONNECTED)
      command.header.flags |= ENET_PROTOCOL_FLAG_ACKNOWLEDGE;
    
    enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0);

    if (peer -> state == ENET_PEER_STATE_CONNECTED)
      peer -> state = ENET_PEER_STATE_DISCONNECTING;
    else
    {
        enet_host_flush (peer -> host);
        enet_peer_reset (peer);
    }
}


Generated by  Doxygen 1.6.0   Back to index