C4 Engine
C4 Engine API Documentation

Application::HandleConnectionEvent

Defined in:  C4Application.h
Called to handle a network connection event.
Prototype

virtual void HandleConnectionEvent(ConnectionEvent event, const NetworkAddress& address, const void *param);

Parameters
event The connection event type. See below for a list of possible types.
address The network address for which the event occurred.
param A pointer to parameter information for the event.
Description
The HandleConnectionEvent function can be overridden by an application-defined subclass of the Application class. This function is called when an event pertaining to a particular connection occurs in a multiplayer game. The event parameter contains one of the following constants.
kConnectionQueryReceived A request for server information has been received.
kConnectionAttemptFailed An attempt to connect to a server has failed.
kConnectionClientOpened A client machine has opened a connection to the server.
kConnectionServerAccepted The server has accepted a connection request.
kConnectionServerClosed The server has closed the connection.
kConnectionClientClosed A client has closed the connection.
kConnectionServerTimedOut The server connection has timed out.
kConnectionClientTimedOut A client connection has timed out.
The server machine can receive events pertaining to connections with any of the client machines. Each client machine only receives events pertaining to the connection with the server.

If the event parameter is kConnectionAttemptFailed, then the param parameter points to a int32 value containing one of the following constants indicating the reason for the failure.
kNetworkFailTimeout The remote machine did not respond and the connection attempt timed out.
kNetworkFailWrongProtocol The remote machine is not using the same communications protocol that the local machine is using.
kNetworkFailNotServer The remote machine is using the correct protocol, but it is not a server.
kNetworkFailServerFull The remote machine did not accept the connection because the maximum number of clients have already connected.
If the event parameter is kConnectionQueryReceived, then the server has received a request for game information. In response, the event handler should send an application-defined message containing information about the server back to the machine from which the query originated. A connection with this machine will not normally exist, so the return message should be sent to the address given by the address parameter using the MessageMgr::SendConnectionlessMessage function.
See Also

Application::HandlePlayerEvent

Application::HandleGameEvent

MessageMgr::BroadcastServerQuery

MessageMgr::SendConnectionlessMessage