diff options
-rw-r--r-- | common/message.h | 24 | ||||
-rw-r--r-- | server/client.cpp | 4 |
2 files changed, 22 insertions, 6 deletions
diff --git a/common/message.h b/common/message.h index 2be68c0..76ebf95 100644 --- a/common/message.h +++ b/common/message.h @@ -62,13 +62,16 @@ namespace Message { public: typedef boost::shared_ptr<Login> p; - Login(const std::string& n = "") : Base(Types::Login), nick(n) {} + Login(const std::string& n = "", uint64_t c = 0) : Base(Types::Login), nick(n), cookie(c) {} std::string nick; + uint64_t cookie; + template<class Archive> void serialize(Archive & ar, const unsigned int v) { ar & nick; + ar & cookie; } }; @@ -76,13 +79,26 @@ namespace Message { public: typedef boost::shared_ptr<LoginResponse> p; - LoginResponse(bool ok = false) : Base(Types::LoginResponse), login_ok(ok) {} + //! Response type. + enum Type { + //! Invalid login attempt. + Invalid, + //! Login to lobby. + Lobby, + //! Login to resume ongoing game. + Resume + }; + + LoginResponse(Type t = Invalid, uint64_t c = 0) : Base(Types::LoginResponse), type(t), cookie(c) {} + + Type type; - bool login_ok; + uint64_t cookie; template<class Archive> void serialize(Archive & ar, const unsigned int v) { - ar & login_ok; + ar & type; + ar & cookie; } }; diff --git a/server/client.cpp b/server/client.cpp index 329da82..07a59f4 100644 --- a/server/client.cpp +++ b/server/client.cpp @@ -39,12 +39,12 @@ void Client::handle_login(Message::p msg, boost::function<void (Client::p)> logi // Check if nick is invalid. if(login_msg->nick.size() == 0) { - connection->send(make_shared<Message::LoginResponse>(false)); + connection->send(make_shared<Message::LoginResponse>(Message::LoginResponse::Invalid)); connection->recv(boost::bind(&Client::handle_login, shared_from_this(), _1, login_callback)); return; } - connection->send(make_shared<Message::LoginResponse>(true)); + connection->send(make_shared<Message::LoginResponse>(Message::LoginResponse::Lobby)); nick_ = login_msg->nick; |