#include <ArServerClient.h>
Public Types | |
| enum | ServerState { STATE_SENT_INTRO, STATE_REJECTED, STATE_CONNECTED, STATE_DISCONNECTED } |
| The state of the connection. More... | |
| STATE_CONNECTED | |
| Client is connected to server. | |
| STATE_DISCONNECTED | |
| Client has disconnected from server. | |
| STATE_REJECTED | |
| Client was rejected by server. | |
| STATE_SENT_INTRO | |
| opened socket, sent our intro to the server | |
Public Member Functions | |
| ArServerClient (ArSocket *tcpSocket, unsigned int udpPort, long authKey, long introKey, ArRetFunctor2< bool, ArNetPacket *, struct sockaddr_in * > *sendUdpCallback, std::map< unsigned int, ArServerData * > *dataMap, const char *passwordKey, const char *serverKey, const ArServerUserInfo *userInfo=NULL, int rejecting=0, const char *rejectingString="", bool debugLogging=false, const char *serverClientName="ArServerBase_unknown", bool logPasswordFailureVerbosely=false, bool allowSlowPackets=true, bool allowIdlePackets=true) | |
| Constructor. | |
| void | broadcastPacketTcp (ArNetPacket *packet) |
| Broadcasts a packet over TCP if this client wants this data -- For internal use only! | |
| void | broadcastPacketUdp (ArNetPacket *packet) |
| Broadcasts a packet over UDP if this client wants this data (unless client only wants tcp then sends over tcp) -- For internal ArNetworking use only! | |
| unsigned int | findCommandFromName (const char *commandName) const |
| Returns the command ID for the specified name, or 0 if it is not found. | |
| void | forceDisconnect (bool quiet) |
| Forcibly disconnect a client (for client/server switching). | |
| long | getAuthKey (void) |
| Gets the authKey used for setting up UDP from this client to the server. | |
| ArTime | getCreationTime (void) |
| Get creation time. | |
| long | getFrequency (ArTypes::UByte2 command) |
| Gets how often a command is asked for. | |
| ArServerClientIdentifier | getIdentifier (void) const |
| Gets the identifier of this server client. | |
| const char * | getIPString (void) const |
| Gets the IP string of the client. | |
| ServerState | getState (void) |
| Gets the state. | |
| ArSocket * | getTcpSocket (void) |
| Internal function to get the tcp socket. | |
| sockaddr_in * | getUdpAddress (void) |
| Gets the sin (network address) for the UDP socket. | |
| void | handleRequests (void) |
| Handles the requests for packets. | |
| bool | hasGroupAccess (const char *group) |
| Sees if this client has access to a given group. | |
| bool | hasIdlePackets (void) |
| Gets if we have any idle packets to process. | |
| bool | hasSlowPackets (void) |
| Gets if we have any slow packets to process. | |
| bool | idlePacketCallback (void) |
| The callback for taking care of idle packets (logic on idle elsewhere). | |
| bool | isTcpOnly (void) |
| Gets the tcp only flag. | |
| void | logTracking (bool terse) |
| Logs the tracking information (packet and byte counts). | |
| void | processAuthPacket (ArNetPacket *packet, struct sockaddr_in *sin) |
| Processes the auth packets that came from udp. | |
| void | processPacket (ArNetPacket *packet, bool tcp=true) |
| Process the packet whever it came from. | |
| void | resetTracking (void) |
| Clears the tracking information (resets counters). | |
| bool | sendPacketTcp (ArNetPacket *packet) |
| Send a packet over TCP. | |
| bool | sendPacketUdp (ArNetPacket *packet) |
| Send a packet over UDP (unless client only wants TCP; then sends over TCP). | |
| void | setBackupTimeout (double timeoutInMins) |
| Sets the backup timeout. | |
| void | setIdentifier (ArServerClientIdentifier identifier) |
| Sets the identifier of this server client. | |
| void | setUdpAddress (struct sockaddr_in *sin) |
| Sets the sin (network address) for the UDP socket. | |
| void | shutdown (void) |
| Sends a shutdown command to the socket. | |
| bool | slowPacketCallback (void) |
| The callback for taking care of slow packets. | |
| bool | tcpCallback (void) |
| The callback for taking care of the TCP connection. | |
| void | useTcpOnly (void) |
| Sets the TCP only flag. | |
| virtual | ~ArServerClient () |
| Destructor. | |
Protected Member Functions | |
| const char * | findCommandName (unsigned int command) const |
| unsigned int | getCommand () |
| bool | getForceTcpFlag () |
| void | internalSwitchState (ServerState state) |
| void | popCommand (void) |
| void | popForceTcpFlag (void) |
| void | popSlowIdleCommand (void) |
| void | popSlowIdleForceTcpFlag (void) |
| void | pushCommand (unsigned int num) |
| void | pushForceTcpFlag (bool forceTcp) |
| void | pushSlowIdleCommand (unsigned int num) |
| void | pushSlowIdleForceTcpFlag (bool forceTcp) |
| void | sendListPacket (void) |
| bool | setupPacket (ArNetPacket *packet) |
| void | trackPacketReceived (ArNetPacket *packet, ArTypes::UByte2) |
| void | trackPacketSent (ArNetPacket *packet, bool tcp) |
Protected Attributes | |
| bool | myAllowIdlePackets |
| bool | myAllowSlowPackets |
| long | myAuthKey |
| double | myBackupTimeout |
| std::list< unsigned int > | myCommandStack |
| ArTime | myCreationTime |
| std::map< unsigned int, ArServerData * > * | myDataMap |
| bool | myDebugLogging |
| std::list< bool > | myForceTcpStack |
| std::set< std::string, ArStrCaseCmpOp > | myGroups |
| bool | myHaveIdlePackets |
| bool | myHaveSlowPackets |
| ArServerClientIdentifier | myIdentifier |
| std::list< ArNetPacket * > | myIdlePackets |
| ArMutex | myIdlePacketsMutex |
| long | myIntroKey |
| std::string | myIPString |
| bool | myLogPasswordFailureVerbosely |
| std::string | myLogPrefix |
| std::string | myPasswordKey |
| ArFunctor2C< ArServerClient, ArNetPacket *, bool > | myProcessPacketCB |
| int | myRejecting |
| std::string | myRejectingString |
| std::list< ArServerClientData * > | myRequested |
| ArRetFunctor2< bool, ArNetPacket *, struct sockaddr_in * > * | mySendUdpCB |
| bool | mySentTcpOnly |
| std::string | myServerKey |
| sockaddr_in | mySin |
| std::list< unsigned int > | mySlowIdleCommandStack |
| std::list< bool > | mySlowIdleForceTcpStack |
| ArThread * | mySlowIdleThread |
| std::list< ArNetPacket * > | mySlowPackets |
| ArMutex | mySlowPacketsMutex |
| ServerState | myState |
| ArTime | myStateStart |
| bool | myTcpOnly |
| ArNetPacketReceiverTcp | myTcpReceiver |
| ArNetPacketSenderTcp | myTcpSender |
| ArSocket | myTcpSocket |
| std::map< ArTypes::UByte2, Tracker * > | myTrackingReceivedMap |
| std::map< ArTypes::UByte2, Tracker * > | myTrackingSentMap |
| ArTime | myTrackingStarted |
| bool | myUdpConfirmedFrom |
| bool | myUdpConfirmedTo |
| const ArServerUserInfo * | myUserInfo |
| ArLog::LogLevel | myVerboseLogLevel |
Classes | |
| class | Tracker |
| ArServerClient::ArServerClient | ( | ArSocket * | tcpSocket, | |
| unsigned int | udpPort, | |||
| long | authKey, | |||
| long | introKey, | |||
| ArRetFunctor2< bool, ArNetPacket *, struct sockaddr_in * > * | sendUdpCallback, | |||
| std::map< unsigned int, ArServerData * > * | dataMap, | |||
| const char * | passwordKey, | |||
| const char * | serverKey, | |||
| const ArServerUserInfo * | userInfo = NULL, |
|||
| int | rejecting = 0, |
|||
| const char * | rejectingString = "", |
|||
| bool | debugLogging = false, |
|||
| const char * | serverClientName = "ArServerBase_unknown", |
|||
| bool | logPasswordFailureVerbosely = false, |
|||
| bool | allowSlowPackets = true, |
|||
| bool | allowIdlePackets = true | |||
| ) |
Constructor.
| tcpSocket | the socket that has been established between the client and the server | |
| udpPort | the udp port the server is using | |
| authKey | this authKey must be presented by the client to the server on the server's UDP port for the client to be recognized by the server | |
| introKey | this key must be presented by the server to the client so that the client will recognize the server | |
| sendUdpCallback | the callback used to send Udp packets (since the udp packets need to be sent from the server's udp port and the serverclient here doesn't have one) | |
| dataMap | the map between command numbers and the command data | |
| passwordKey | the key (just plain text thats used in an md5 along with the serverKey and the password over on the client side) that was generated for the passwords on this exact connection | |
| serverKey | the key (just plain text thats used in an md5 along with the passwordKey and the password over on the client side) that should be used for any connections to this server | |
| debugLogging | If true, log some debug messages | |
| logPasswordFailureVerbosely | If true, log password errors at ArLog::Verbose level, if false, log them at ArLog::Normal level. | |
| userInfo | the pointer to the item that holds our usernames and passwords |
| ArServerClient::~ArServerClient | ( | ) | [virtual] |
Destructor.
MPL fixing a memory leak
| void ArServerClient::broadcastPacketTcp | ( | ArNetPacket * | packet | ) |
Broadcasts a packet over TCP if this client wants this data -- For internal use only!
For internal use only.
| void ArServerClient::broadcastPacketUdp | ( | ArNetPacket * | packet | ) |
Broadcasts a packet over UDP if this client wants this data (unless client only wants tcp then sends over tcp) -- For internal ArNetworking use only!
For internal use only.
| unsigned int ArServerClient::findCommandFromName | ( | const char * | commandName | ) | const |
Returns the command ID for the specified name, or 0 if it is not found.
| const char * ArServerClient::findCommandName | ( | unsigned int | command | ) | const [protected] |
| void ArServerClient::forceDisconnect | ( | bool | quiet | ) |
Forcibly disconnect a client (for client/server switching).
| long ArServerClient::getAuthKey | ( | void | ) |
Gets the authKey used for setting up UDP from this client to the server.
| unsigned int ArServerClient::getCommand | ( | ) | [protected] |
| ArTime ArServerClient::getCreationTime | ( | void | ) | [inline] |
Get creation time.
| bool ArServerClient::getForceTcpFlag | ( | ) | [protected] |
| long ArServerClient::getFrequency | ( | ArTypes::UByte2 | command | ) |
Gets how often a command is asked for.
| command | the command number, you can use findCommandFromName |
| ArServerClientIdentifier ArServerClient::getIdentifier | ( | void | ) | const |
Gets the identifier of this server client.
| const char * ArServerClient::getIPString | ( | void | ) | const |
Gets the IP string of the client.
| ServerState ArServerClient::getState | ( | void | ) | [inline] |
Gets the state.
| ArSocket* ArServerClient::getTcpSocket | ( | void | ) | [inline] |
Internal function to get the tcp socket.
| struct sockaddr_in * ArServerClient::getUdpAddress | ( | void | ) |
Gets the sin (network address) for the UDP socket.
| void ArServerClient::handleRequests | ( | void | ) |
Handles the requests for packets.
| bool ArServerClient::hasGroupAccess | ( | const char * | group | ) |
Sees if this client has access to a given group.
| bool ArServerClient::hasIdlePackets | ( | void | ) | [inline] |
Gets if we have any idle packets to process.
| bool ArServerClient::hasSlowPackets | ( | void | ) | [inline] |
Gets if we have any slow packets to process.
| bool ArServerClient::idlePacketCallback | ( | void | ) |
The callback for taking care of idle packets (logic on idle elsewhere).
| void ArServerClient::internalSwitchState | ( | ServerState | state | ) | [protected] |
| bool ArServerClient::isTcpOnly | ( | void | ) | [inline] |
Gets the tcp only flag.
| void ArServerClient::logTracking | ( | bool | terse | ) |
Logs the tracking information (packet and byte counts).
| void ArServerClient::popCommand | ( | void | ) | [protected] |
| void ArServerClient::popForceTcpFlag | ( | void | ) | [protected] |
| void ArServerClient::popSlowIdleCommand | ( | void | ) | [protected] |
| void ArServerClient::popSlowIdleForceTcpFlag | ( | void | ) | [protected] |
| void ArServerClient::processAuthPacket | ( | ArNetPacket * | packet, | |
| struct sockaddr_in * | sin | |||
| ) |
Processes the auth packets that came from udp.
| void ArServerClient::processPacket | ( | ArNetPacket * | packet, | |
| bool | tcp = true | |||
| ) |
Process the packet whever it came from.
| void ArServerClient::pushCommand | ( | unsigned int | num | ) | [protected] |
| void ArServerClient::pushForceTcpFlag | ( | bool | forceTcp | ) | [protected] |
| void ArServerClient::pushSlowIdleCommand | ( | unsigned int | num | ) | [protected] |
| void ArServerClient::pushSlowIdleForceTcpFlag | ( | bool | forceTcp | ) | [protected] |
| void ArServerClient::resetTracking | ( | void | ) |
Clears the tracking information (resets counters).
| void ArServerClient::sendListPacket | ( | void | ) | [protected] |
| bool ArServerClient::sendPacketTcp | ( | ArNetPacket * | packet | ) |
Send a packet over TCP.
The command ID of the outgoing packet will be set to the current command ID (from the incoming packet).
| bool ArServerClient::sendPacketUdp | ( | ArNetPacket * | packet | ) |
Send a packet over UDP (unless client only wants TCP; then sends over TCP).
The command ID of the outgoing packet will be set to the current command ID (from the incoming packet).
| void ArServerClient::setBackupTimeout | ( | double | timeoutInMins | ) |
Sets the backup timeout.
| void ArServerClient::setIdentifier | ( | ArServerClientIdentifier | identifier | ) |
Sets the identifier of this server client.
| void ArServerClient::setUdpAddress | ( | struct sockaddr_in * | sin | ) |
Sets the sin (network address) for the UDP socket.
| bool ArServerClient::setupPacket | ( | ArNetPacket * | packet | ) | [protected] |
| void ArServerClient::shutdown | ( | void | ) |
Sends a shutdown command to the socket.
| bool ArServerClient::slowPacketCallback | ( | void | ) |
The callback for taking care of slow packets.
| bool ArServerClient::tcpCallback | ( | void | ) |
The callback for taking care of the TCP connection.
| void ArServerClient::trackPacketReceived | ( | ArNetPacket * | packet, | |
| ArTypes::UByte2 | ||||
| ) | [protected] |
| void ArServerClient::trackPacketSent | ( | ArNetPacket * | packet, | |
| bool | tcp | |||
| ) | [protected] |
| void ArServerClient::useTcpOnly | ( | void | ) | [inline] |
Sets the TCP only flag.
bool ArServerClient::myAllowIdlePackets [protected] |
bool ArServerClient::myAllowSlowPackets [protected] |
long ArServerClient::myAuthKey [protected] |
double ArServerClient::myBackupTimeout [protected] |
std::list<unsigned int> ArServerClient::myCommandStack [protected] |
ArTime ArServerClient::myCreationTime [protected] |
std::map<unsigned int, ArServerData *>* ArServerClient::myDataMap [protected] |
bool ArServerClient::myDebugLogging [protected] |
std::list<bool> ArServerClient::myForceTcpStack [protected] |
std::set<std::string, ArStrCaseCmpOp> ArServerClient::myGroups [protected] |
bool ArServerClient::myHaveIdlePackets [protected] |
bool ArServerClient::myHaveSlowPackets [protected] |
ArServerClientIdentifier ArServerClient::myIdentifier [protected] |
std::list<ArNetPacket *> ArServerClient::myIdlePackets [protected] |
ArMutex ArServerClient::myIdlePacketsMutex [protected] |
long ArServerClient::myIntroKey [protected] |
std::string ArServerClient::myIPString [protected] |
bool ArServerClient::myLogPasswordFailureVerbosely [protected] |
std::string ArServerClient::myLogPrefix [protected] |
std::string ArServerClient::myPasswordKey [protected] |
ArFunctor2C<ArServerClient, ArNetPacket *, bool> ArServerClient::myProcessPacketCB [protected] |
int ArServerClient::myRejecting [protected] |
std::string ArServerClient::myRejectingString [protected] |
std::list<ArServerClientData *> ArServerClient::myRequested [protected] |
ArRetFunctor2<bool, ArNetPacket *, struct sockaddr_in *>* ArServerClient::mySendUdpCB [protected] |
bool ArServerClient::mySentTcpOnly [protected] |
std::string ArServerClient::myServerKey [protected] |
struct sockaddr_in ArServerClient::mySin [protected] |
std::list<unsigned int> ArServerClient::mySlowIdleCommandStack [protected] |
std::list<bool> ArServerClient::mySlowIdleForceTcpStack [protected] |
ArThread* ArServerClient::mySlowIdleThread [protected] |
std::list<ArNetPacket *> ArServerClient::mySlowPackets [protected] |
ArMutex ArServerClient::mySlowPacketsMutex [protected] |
ServerState ArServerClient::myState [protected] |
ArTime ArServerClient::myStateStart [protected] |
bool ArServerClient::myTcpOnly [protected] |
ArNetPacketReceiverTcp ArServerClient::myTcpReceiver [protected] |
ArNetPacketSenderTcp ArServerClient::myTcpSender [protected] |
ArSocket ArServerClient::myTcpSocket [protected] |
std::map<ArTypes::UByte2, Tracker *> ArServerClient::myTrackingReceivedMap [protected] |
std::map<ArTypes::UByte2, Tracker *> ArServerClient::myTrackingSentMap [protected] |
ArTime ArServerClient::myTrackingStarted [protected] |
bool ArServerClient::myUdpConfirmedFrom [protected] |
bool ArServerClient::myUdpConfirmedTo [protected] |
const ArServerUserInfo* ArServerClient::myUserInfo [protected] |
ArLog::LogLevel ArServerClient::myVerboseLogLevel [protected] |
1.4.7