Main Page   Class Hierarchy   Compound List   File List   Compound Members  

NetManagerClient Class Reference

Client network manager class for Perihelion. More...

#include <netmanagerclient.h>

Inheritance diagram for NetManagerClient:

Inheritance graph
[legend]
Collaboration diagram for NetManagerClient:

Collaboration graph
[legend]
List of all members.

Public Methods

 NetManagerClient (const string &server)
 Creates a client NetManager object, "connected" to the indicated server. More...

 ~NetManagerClient ()
 Flushes the remaining data, closes the socket and destroys all the data structures.

void send (MessagePacket &msg)
 Sends a message to the server. More...

void send (const string &msg)
 Sends a single message to the server. More...

MessagePacket next ()
 Returns the next MessagePacket received from the socket. More...

void flush ()
 Flushes the output socket. More...

int getClientID () const
 Returns our client index in the server. More...


Private Methods

virtual bool forwardMessage (const MessagePacket &msg, IPaddress *ip)
 Determines whether the message should or not be forwarded to the user. More...


Private Attributes

MessagePacket outputBuffer
 Contains the unsent message packets. More...

int clientID
 Identifies the client in the server list. More...


Detailed Description

Client network manager class for Perihelion.

Client network manager class for Perihelion, with capabilities to send and receive MessagePacket objects, and return them to the class' users.

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.


Constructor & Destructor Documentation

NetManagerClient::NetManagerClient const string &    server
 

Creates a client NetManager object, "connected" to the indicated server.

Creates a client NetManager object, "connected" to the indicated server. The server address can be both in numeric or alphanumeric format, and there is no need to specify the port, since there is a fixed one. This could raise an exception if something goes wrong

Parameters:
server  indicates the server to which we should connect, in either numeric or alphanumeric string format. There is no need for a port in the address.


Member Function Documentation

void NetManagerClient::flush  
 

Flushes the output socket.

Flushes the output socket sending all the contained information. This method should be called once in a while, so that the size of the message to be send doesn't exceed the packet size. This method can raise exceptions if something goes wrong, so please catch the 'string'.

bool NetManagerClient::forwardMessage const MessagePacket   msg,
IPaddress *    ip
[private, virtual]
 

Determines whether the message should or not be forwarded to the user.

Returns:
a boolean telling whether the message must pass or not.

Implements NetManager.

int NetManagerClient::getClientID   const [inline]
 

Returns our client index in the server.

Returns the client index of the client, as established by the server.

Returns:
an int indicating the index of our player in the game.

MessagePacket NetManagerClient::next  
 

Returns the next MessagePacket received from the socket.

Returns the next MessagePacket received from the socket. There is no need to indicate a socket number, since we are in the client and there is only one. This method can raise exceptions if something goes wrong, so please catch the 'string'.

Returns:
the next MessagePacket in the queue for socketIndex

void NetManagerClient::send const string &    msg
 

Sends a single message to the server.

Sends a single message to the server through the receiverSocket, which is also used to read messages from it. $$$ Actually, we still have to decide whether the message is sent or just scheduled for later delivery, until 'flush' is called. There is no need to indicate either a destination or source, since all the messages arrive to the server from this client, and can be identified as is. This method could raise exceptions when something fails, so please enclose its calls within a try-catch block.

Parameters:
msg  the message string to be sent.

void NetManagerClient::send MessagePacket   msg
 

Sends a message to the server.

Sends a message to the server through the receiverSocket, which is also used to read messages from it. There is no need to set the client index number in the packet, since this is done inside the method. $$$ Actually, we still have to decide whether the message is sent or just scheduled for later delivery, until 'flush' is called. There is no need to indicate a destination, since all the messages arrive to the server. This method could raise exceptions when something fails, so please enclose its calls within a try-catch block.

Parameters:
msg  the actual message to be sent.


Member Data Documentation

int NetManagerClient::clientID [private]
 

Identifies the client in the server list.

Identifies the client in the server list. Must be sent in each packet to make it easier for the server to keep track.

MessagePacket NetManagerClient::outputBuffer [private]
 

Contains the unsent message packets.

Contains the unsent message packets ready to be delivered. Messages are appended to each other, so that only one packet is sent afterwards, when flush is called.


The documentation for this class was generated from the following files:
Generated on Thu Jun 6 17:22:22 2002 for Perihelion by doxygen1.2.15