00001 #ifndef ERIS_LOBBY_H
00002 #define ERIS_LOBBY_H
00003
00004 #include <sigc++/object.h>
00005 #if SIGC_MAJOR_VERSION == 1 && SIGC_MINOR_VERSION == 0
00006 #include <sigc++/basic_signal.h>
00007 #else
00008 #include <sigc++/signal.h>
00009 #endif
00010
00011 #include <Atlas/Objects/Entity/Player.h>
00012 #include <Atlas/Objects/Operation/Info.h>
00013
00014 #include <Eris/Types.h>
00015 #include <Eris/Connection.h>
00016 #include <Eris/Room.h>
00017
00018
00019 class TestLobby;
00020
00021 namespace Eris
00022 {
00023
00024 class Player;
00025 class Person;
00026
00029 class Lobby : public Room
00030 {
00031 public:
00032 Lobby(Connection *c);
00033 virtual ~Lobby();
00034
00036 Room* join(const std::string &roomID);
00037
00038
00039
00041 Person* getPerson(const std::string &acc);
00042
00044 Room* getRoom(const std::string &id);
00045
00047 const std::string& getAccountID();
00048
00050 Connection* getConnection() const { return _con; }
00051
00052
00054
00055
00057
00058
00059
00060 SigC::Signal2<void, const std::string&, const std::string&> PrivateTalk;
00061
00063 SigC::Signal1<void, const Atlas::Objects::Entity::Player&> LoggedIn;
00064
00068 static Lobby* getPrimary() {return Connection::getPrimary()->getLobby();}
00070 static Lobby* instance() {return getPrimary();}
00071 protected:
00072 friend class Room;
00073 friend class Player;
00074
00075 friend class TestLobby;
00076
00077 void look(const std::string &id);
00078 void expectInfoRefno(long ref);
00079
00080
00081 void recvInfoAccount(const Atlas::Objects::Operation::Info &ifo,
00082 const Atlas::Objects::Entity::Account &account);
00083
00084 void recvSightPerson(const Atlas::Objects::Entity::Account &ac);
00085 void recvSightRoom(const Atlas::Objects::Entity::RootEntity &room);
00086
00087 void recvSightLobby(const Atlas::Objects::Entity::RootEntity &lobby);
00088
00089 void recvPrivateChat(const Atlas::Objects::Operation::Talk &tk);
00090
00091 void recvSightCreate(const Atlas::Objects::Operation::Create &cr,
00092 const Atlas::Objects::Entity::RootEntity &ent);
00093
00095 void processRoomCreate(const Atlas::Objects::Operation::Create &cr,
00096 const Atlas::Objects::Entity::RootEntity &ent);
00097
00099 void registerCallbacks();
00100
00104 void addPendingCreate(Room *r, int serialno);
00105
00106
00107 void netFailure(const std::string& msg);
00108 void netConnected();
00109 void netDisconnected();
00110
00111 std::string _account;
00112 Connection* _con;
00113
00114 bool _reconnect;
00115 long _infoRefno;
00116
00117 typedef std::map<std::string, Person*> PersonDict;
00118 PersonDict _peopleDict;
00119
00120 typedef std::map<std::string, Room*> RoomDict;
00121 RoomDict _roomDict;
00122
00123 typedef std::map<int, Room*> PendingCreateMap;
00125 PendingCreateMap _pendingCreate;
00126 };
00127
00128 }
00129
00130 #endif