#include <netcomputer.hpp>
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. |
For example a connected client or a server we're connected to.
Definition at line 35 of file netcomputer.hpp.
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.
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().
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.