src/Clientfsm.h

00001 #ifndef CLIENTFSM_H_
00002 #define CLIENTFSM_H_
00003 
00004 #include <SDL.h>
00005 #include <SDL_net.h>
00006 
00007 class Connection;               // Forward declarations.
00008 class ConnectionData;
00009 class Message;
00010 class MessageIn;
00011 class MessageOut;
00012 class Logger;
00013 class Server;
00014 class Client;
00015 
00016 #define KEEPALIVE_TIME          (1000)  
00017 #define KEEPALIVE_TIMEOUT       (4000)          
00019 enum client_fsm_trans {t_ack_time, t_login, t_login_ok, t_login_failed, t_ka_ack_sent,
00020                                                 t_ka_received, t_ka_timeout, t_sck_down, t_disconnect};
00021 
00025 class ClientFSM {
00026 
00027         public:
00038         ClientFSM(ConnectionData *data, Server* server, Client* client);
00039 
00047         void Start(void);
00048 
00056         void Evolve(void);
00057 
00065         void Stop(void);
00066 
00075         bool getStatus(void);
00076 
00077 protected:
00086         bool ExecTrans(client_fsm_trans t);
00087 
00088         void (ClientFSM::*ExecState)(void);
00089 
00091         // Machine States START
00093 
00101         void SendKA_ACK(void);
00102 
00110         void Ready(void);
00111 
00120         void Login(void);
00121 
00128         void Disconnect(void);
00129 
00137         void ResetKATime(void);
00138 
00140         // Machine States STOP
00142 
00143 
00144 
00145 private:
00157         bool authenticate(MessageIn *msg);
00158 
00167     void chat(MessageIn* message);
00168 
00177     void move(MessageIn* message);
00178 
00179 private:
00180 
00181         bool endFSM;                    
00182         ConnectionData * data;  
00183         SDLNet_SocketSet set;   
00184         unsigned char livePtr;  
00185         Uint32 lastKA;                  
00186         Logger* logger;         
00187         Server* myServer;       
00188         Client* myClient;       
00189 };
00190 
00191 #endif /*CLIENTFSM_H_*/

Generated on Mon Dec 3 04:30:12 2007 for lo-testserver by  doxygen 1.3.9.1