ArServerClient Class Reference

#include <ArServerClient.h>

List of all members.


Detailed Description

This class represents the server's connection to the client, and contains the socket that the server uses to talk to the client and the information for sending packets to the client.


Public Types

enum  ServerState { STATE_SENT_INTRO, STATE_REJECTED, STATE_CONNECTED, STATE_DISCONNECTED }
 The state of the connection. More...

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)
void broadcastPacketUdp (ArNetPacket *packet)
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.
ArSocketgetTcpSocket (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)
bool sendPacketUdp (ArNetPacket *packet)
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, ArStrCaseCmpOpmyGroups
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
ArThreadmySlowIdleThread
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 ArServerUserInfomyUserInfo
ArLog::LogLevel myVerboseLogLevel


Member Enumeration Documentation

enum ArServerClient::ServerState

The state of the connection.

Enumerator:
STATE_SENT_INTRO  opened socket, sent our intro to the server
STATE_REJECTED  Client was rejected by server.
STATE_CONNECTED  Client is connected to server.
STATE_DISCONNECTED  Client has disconnected from server.


Member Function Documentation

void ArServerClient::broadcastPacketTcp ( ArNetPacket packet  ) 

Broadcasts a packet over TCP if this client wants this data -- 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!

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).


The documentation for this class was generated from the following file:
Generated on Thu Aug 6 09:40:12 2009 for ArNetworking by  doxygen 1.5.1