#include <connectionhandler.hpp>
Public Member Functions | |
bool | startListen (enet_uint16 port) |
Open the server socket. | |
void | stopListen () |
Disconnect all the clients and close the server socket. | |
virtual void | process (enet_uint32 timeout=0) |
Process outgoing messages and listen to the server socket for incoming messages and new connections. | |
void | flush () |
Process outgoing messages. | |
void | sendToEveryone (const MessageOut &msg) |
Called when a computer sends a packet to the network session. | |
unsigned int | getClientNumber () |
Return the number of connected clients. | |
Protected Types | |
typedef std::list< NetComputer * > | NetComputers |
Protected Member Functions | |
virtual NetComputer * | computerConnected (ENetPeer *peer)=0 |
Called when a computer connects to the server. | |
virtual void | computerDisconnected (NetComputer *)=0 |
Called when a computer reconnects to the server. | |
virtual void | processMessage (NetComputer *, MessageIn &)=0 |
Called when a message is received. | |
Protected Attributes | |
NetComputers | clients |
A list of pointers to the client structures created by computerConnected. |
The connection handler will respond to connect/reconnect/disconnect events and handle incoming messages, passing them on to registered message handlers.
Definition at line 37 of file connectionhandler.hpp.
void ConnectionHandler::process | ( | enet_uint32 | timeout = 0 |
) | [virtual] |
Process outgoing messages and listen to the server socket for incoming messages and new connections.
an optional timeout in milliseconds to wait for something to happen when there is nothing to do
Definition at line 76 of file connectionhandler.cpp.
References clients, computerConnected(), computerDisconnected(), and processMessage().
void ConnectionHandler::sendToEveryone | ( | const MessageOut & | msg | ) |
Called when a computer sends a packet to the network session.
Send packet to every client, used for announcements.
Definition at line 138 of file connectionhandler.cpp.
References clients.
virtual NetComputer* ConnectionHandler::computerConnected | ( | ENetPeer * | peer | ) | [protected, pure virtual] |
Called when a computer connects to the server.
Initialize an object derived of NetComputer.
Implemented in ServerHandler, ChatHandler, and GameHandler.
Referenced by process().
virtual void ConnectionHandler::computerDisconnected | ( | NetComputer * | ) | [protected, pure virtual] |
Called when a computer reconnects to the server.
Called when a computer disconnects from the server.
Note: After returning from this method the NetComputer reference is no longer guaranteed to be valid.
Implemented in ServerHandler, ChatHandler, and GameHandler.
Referenced by process().