diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/client.cpp | 15 | ||||
-rw-r--r-- | server/client.h | 9 |
2 files changed, 7 insertions, 17 deletions
diff --git a/server/client.cpp b/server/client.cpp index 533f6ee..465da3b 100644 --- a/server/client.cpp +++ b/server/client.cpp @@ -60,7 +60,7 @@ void Client::handle_action(Message::p msg, boost::function<void (Action)> action if(possible_actions.contains(action_msg->action)) { action_callback(action_msg->action); } else { - action_callback(possible_actions[0]); + action_callback(possible_actions.back()); } } @@ -68,13 +68,12 @@ std::string Client::nick() { return nick_; } -void Client::game_start(boost::function<void ()> callback, std::vector<Client::p> players) { +void Client::game_start(boost::function<void ()> callback, std::vector<std::string> players) { Message::GameStart::p msg = make_shared<Message::GameStart>(); - for(std::vector<Client::p>::iterator i = players.begin(); i != players.end(); i++) { - msg->players.push_back((*i)->nick()); - } - msg->player_id = id; + msg->players = players; + + msg->player_id = 0; connection->send(msg); @@ -96,7 +95,3 @@ void Client::round_end() { void Client::get_action(boost::function<void (Action)> callback, Actions expected_actions) { connection->recv(boost::bind(&Client::handle_action, shared_from_this(), _1, callback, expected_actions)); } - -void Client::kill_action() { - -} diff --git a/server/client.h b/server/client.h index ad5df64..ec22e85 100644 --- a/server/client.h +++ b/server/client.h @@ -37,14 +37,11 @@ class Client : public boost::enable_shared_from_this<Client> { void handle_action(Message::p msg, boost::function<void (Action)> action_callback, Actions expected_actions); public: - //! The ID of the client - int id; - //! Return client's nick. std::string nick(); //! Notify client of a game start. - void game_start(boost::function<void ()> callback, std::vector<Client::p> players); + void game_start(boost::function<void ()> callback, std::vector<std::string> players); //! Notify client of a round start. void round_start(); @@ -55,10 +52,8 @@ class Client : public boost::enable_shared_from_this<Client> { //! Send round end. void round_end(); - //! Get action. + //! Get action. Upon connection error, last element of expected_actions will be provided. void get_action(boost::function<void (Action)> callback, Actions expected_actions); - - void kill_action(); }; typedef std::vector<Client> Clients; |