00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef CLIENTCX_HH_
00014 # define CLIENTCX_HH_
00015
00016 # include "tools.hh"
00017 # include "xml/xml_config.hh"
00018 # include "PacketSender.hh"
00019 # include "BaseCRules.hh"
00020
00021 class Cx;
00022
00030 class ClientCx : public PacketSender
00031 {
00032 public:
00033 ClientCx();
00034 virtual ~ClientCx();
00035
00039 bool connect(xml::XMLConfig& cfg);
00040
00045 bool join(xml::XMLConfig& cfg, const struct RuleDescription& desc);
00046
00049 bool openLog(const std::string& filename);
00050
00052 void disconnect(bool send_abort = false);
00053
00055 bool isConnected() const;
00056
00059 bool process(bool block = false);
00060
00062 void setRules(BaseCRules* rules);
00063
00065 void setClientGameId(int client_gid);
00066
00069 void setReady();
00070
00071 private:
00073 virtual void sendPacket(const Packet& p);
00074
00075 virtual void gameFinished();
00076
00078 bool connect(const std::string& host, int port);
00079 bool join(int game_uid, bool wanna_be_viewer, const struct RuleDescription& desc);
00080
00082 void createDirectCx(int uid);
00083 bool syncArbiter();
00084
00085 Cx* cx_;
00086 BaseCRules* rules_;
00087 int client_gid_;
00088 };
00089
00090 #endif