NetComputer Class Reference

This class represents a known computer on the network. More...

#include <netcomputer.hpp>

Inheritance diagram for NetComputer:

AccountClient ChatClient GameServer

List of all members.

Public Member Functions

 NetComputer (ENetPeer *peer)
 Constructor.
virtual ~NetComputer ()
 Destructor.
bool isConnected ()
 Returns true if this computer is connected.
void disconnect (const MessageOut &msg)
 Disconnects the computer from the server, after sending a message.
void send (const MessageOut &msg, bool reliable=true, unsigned int channel=0)
 Queues a message for sending to a client.
int getIP () const
 Returns IP address of computer in 32bit int form.

Friends

std::ostream & operator<< (std::ostream &os, const NetComputer &comp)
 Converts the ip-address of the peer to a stringstream.


Detailed Description

This class represents a known computer on the network.

For example a connected client or a server we're connected to.

Definition at line 35 of file netcomputer.hpp.


Member Function Documentation

void NetComputer::disconnect ( const MessageOut msg  ) 

Disconnects the computer from the server, after sending a message.

The caller of this method should prepare the message, because NetComputer does not know which handler is sending it (could have been chat/game/account)

Definition at line 45 of file netcomputer.cpp.

References isConnected(), and send().

Referenced by ChatHandler::deletePendingClient().

void NetComputer::send ( const MessageOut msg,
bool  reliable = true,
unsigned int  channel = 0 
)

Queues a message for sending to a client.

Reliable packets always arrive, if the client stays connected. Unreliable packets may not arrive, and may not even be sent.

Channels are used to ensure that unrelated reliable packets do not hold each other up. In essence, each channel represents a different queue.

Parameters:
msg The message to be sent.
reliable Defines if a reliable or an unreliable packet should be sent.
channel The channel number of which the packet should be sent.

Definition at line 62 of file netcomputer.cpp.

References MessageOut::getData(), and MessageOut::getLength().

Referenced by disconnect(), ChatHandler::processMessage(), ServerHandler::processMessage(), GameHandler::sendError(), ChatHandler::sendGuildRejoin(), and ChatHandler::tokenMatched().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const NetComputer comp 
) [friend]

Converts the ip-address of the peer to a stringstream.

Example: std::cout << comp

Definition at line 84 of file netcomputer.cpp.


The documentation for this class was generated from the following files:

Generated on Sun Apr 26 17:30:46 2009 for TMW Server Collection by  doxygen 1.5.5