Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

client.h

00001 #ifdef HAVE_SDL_NET
00002 
00003 #ifndef CLIENT_H
00004 #define CLIENT_H
00005 
00006 #include "../constants.h"
00007 #include "../persist.h"
00008 #include "tcputil.h"
00009 #include "gamestatehandler.h"
00010 #include "testgamestatehandler.h"
00011 #include "broadcast.h"
00012 #include "commands.h"
00013 
00014 int clientLoop(void *data);
00015 
00016 class Client {
00017  private:
00018   char *host;
00019   int port;
00020   char *username;
00021   bool connected;
00022   bool readError;
00023   bool threadRunning;
00024   SDL_Thread *thread;
00025   GameStateHandler *gsh;
00026   int lastGameFrameReceived;
00027   TCPsocket tcpSocket;
00028   Broadcast *broadcast;
00029   IPaddress ip;
00030   Commands *commands;
00031   bool tryToReconnect;
00032 
00033   static const Uint32 FIND_SERVER_TIMEOUT = 10000;
00034 
00035  public:
00036   Client(char *host, int port, char *username, CommandInterpreter *ci);
00037   virtual ~Client();
00038   int connect();
00039   bool findServer();
00040   int login();
00041   int sendChatTCP(char *message);
00042   int sendPing();
00043   // if length==0, s is assumed to be a 0-terminated string
00044   int sendRawTCP(char *s, int length=0);
00045   int sendCharacter(CreatureInfo *info);
00046 
00047   inline void setGameStateHandler(GameStateHandler *gsh) { this->gsh = gsh; }
00048   inline GameStateHandler *getGameStateHandler() { return gsh; }
00049   inline Commands *getCommands() { return commands; }
00050   inline void setTryToReconnect(bool b) { tryToReconnect = b; }
00051   inline bool getTryToReconnect() { return tryToReconnect; }
00052 
00053   inline bool isConnected() { return connected; }
00054   inline bool isThreadRunning() { return threadRunning; }
00055   inline void setThreadRunning(bool b) { threadRunning = b; }
00056   inline TCPsocket getTCPSocket() { return tcpSocket; }
00057   inline void setReadError(bool b) { readError = b; }
00058   inline Broadcast *getBroadcast() { return broadcast; }
00059 
00060  protected:
00061   int openConnection();
00062   void closeConnection();
00063   int initTCPSocket();
00064 };
00065 
00066 #endif
00067 
00068 #endif

Generated on Thu Jun 16 21:50:42 2005 for scourge by  doxygen 1.4.0