#include <netmanagerserver.h>
Inheritance diagram for NetManagerServer:
Public Methods | |
NetManagerServer () | |
Creates a server NetManager. More... | |
~NetManagerServer () | |
Flushes the remaining data, closes the socket and destroys all the data structures. | |
void | send (MessagePacket &msg, unsigned socketIndex, bool immediate=true) |
Sends a message packet through the indicated socket. More... | |
void | send (const string &msg, unsigned socketIndex, bool immediate=true) |
Sends a single message through the indicated socket. More... | |
void | flush (unsigned socketIndex) |
Flushes an output socket. More... | |
MessagePacket | next () |
Returns the next received MessagePacket. More... | |
vector< int > | getNewClients () |
Returns the list of newly connected clients. More... | |
vector< int > | getTimedOutClients () |
Returns the list of timed out clients. More... | |
bool | thereAreNewClients () const |
Determines whether there are newly connected clients. More... | |
bool | thereAreTimedOutClients () const |
Determines whether there are some just timed out clients. More... | |
void | dismissClient (int client) |
Stops keeping control of a certain client. More... | |
void | flush () |
Flushes all the output sockets. More... | |
bool | isTimedOut (unsigned client) const |
Tells if one client is or not timed out. More... | |
Static Public Attributes | |
const Uint32 | TIMEOUT = 60*1000 |
Number of milliseconds after which a client will be considered timed out. More... | |
Private Methods | |
virtual void | onReception (unsigned client) |
Method called after reception of a packet from a certain client. More... | |
virtual bool | forwardMessage (const MessagePacket &msg, IPaddress *ip) |
Determines whether the message should or not be forwarded to the user. More... | |
int | findClient (const IPaddress *ip) const |
Finds a client by checking its IP. More... | |
int | registerClient (IPaddress *ip) |
Registers a new client. More... | |
void | acknowledgeClient (int client) |
Sends an empty acknowledge MessagePacket to the 'client'. More... | |
Private Attributes | |
vector< UDPsocket > | senderSockets |
Vector of sockets used to send data. More... | |
vector< MessagePacket > | outputBuffer |
Contains the unsent message packets for each destination socket. More... | |
vector< bool > | validClients |
Keeps the state of the controlled clients. More... | |
int | msgCount |
Counts the number of available messages to be read. | |
vector< int > | newClients |
Maintains a list of the newly connected clients. | |
vector< int > | timedOutClients |
Maintains a list of the just timed out clients. | |
vector< Uint32 > | lastMsgTime |
Vector containing the SDL time in which we received the last message from each client. |
Server network manager class for Perihelion, with capabilities to send and receive MessagePacket objects, and return them to the class' users, which will be the game server.
Please be aware of methods that can throw exceptions when indicated.
Note: Unless we find an use for them, channels in UCP sockets will be ignored, and 0 will be used by default.
|
Creates a server NetManager. Creates a server NetManager object, ready to listen for requests Closes the socket and destroys all the data structures |
|
Sends an empty acknowledge MessagePacket to the 'client'.
|
|
Stops keeping control of a certain client. Stops keeping control of a certain client, which now will have to make a new service request in order to get in the game.
|
|
Finds a client by checking its IP. Finds a client by checking its IP, and comparing it with all the available clients.
|
|
Flushes all the output sockets. Flushes all the output sockets in the NetManager. This method can raise exceptions if something goes wrong, so please catch the 'string'. |
|
Flushes an output socket. Flushes the indicated output socket. It can flush just one single socket. This method can raise exceptions if something goes wrong, so please catch the 'string'.
|
|
Determines whether the message should or not be forwarded to the user.
Implements NetManager. |
|
Returns the list of newly connected clients. Returns the list of newly connected clients, in the form of a vector<int>. Each element in that vector represents the desired index for the new player, which should be used as-is along the whole system.
|
|
Returns the list of timed out clients. Returns the list of timed out clients, in the form of a vector<int>. Each element in that vector represents the index of the player to dismiss, which should be used as-is along the whole system. The next time this method is called, these clients won't appear again.
|
|
Tells if one client is or not timed out. After a certain amount of time specified in NetManagerServer::TIMEOUT, every client that hasn't sent any message will be considered timed out, and then no one of its messages will be attended.
|
|
Returns the next received MessagePacket. Returns the next MessagePacket received from the receiverSocket, if there is one ready. This method can raise exceptions if something goes wrong, so please catch the 'string'.
|
|
Method called after reception of a packet from a certain client. Updates the timeout counter for the indicated client
Reimplemented from NetManager. |
|
Registers a new client. Registers a new client and sets up the data structures needed to manage it.
|
|
Sends a single message through the indicated socket. Sends a single message through a socket determined by the socketIndex. Actually, depending on the 'immediate' parameter, this method can send the message or schedule it for later delivery, when 'flush' is called. This method could raise exceptions when something fails, so please enclose its calls within a try-catch block.
|
|
Sends a message packet through the indicated socket. Sends a message packet through a socket determined by the socketIndex. There is no need to set the client index number in the packet, since this is done inside the method. Actually, depending on the 'immediate' parameter, this method can send the message or schedule it for later delivery, when 'flush' is called. This method could raise exceptions when something fails, so please enclose its calls within a try-catch block.
|
|
Determines whether there are newly connected clients. Determines whether there are newly connected clients as returned by 'getNewClients'.
|
|
Determines whether there are some just timed out clients. Determines whether there are some just timed out clients as returned by 'getTimedOutClients'.
|
|
Contains the unsent message packets for each destination socket. Contains the unsent message packets for each destination socket. Messages are appended to each other, so that only one packet is sent afterwards to each destination. |
|
Vector of sockets used to send data. Vector of sockets used to send data from the server to the clients |
|
Number of milliseconds after which a client will be considered timed out. Number of milliseconds that a client can remain innactive in a game, before the server considers him timed out and then disregards him. |
|
Keeps the state of the controlled clients. Keeps the state (valid/not valid) of the controlled clients. True means 'valid', and false means 'not valid' (duh!) |