feat: full flow from startup to gameplay & clues sending
This commit is contained in:
parent
c765f7daf9
commit
261694773f
9 changed files with 213 additions and 12 deletions
|
|
@ -34,8 +34,6 @@ void handle_ok(zmq::multipart_t const &message) {
|
|||
}
|
||||
|
||||
void handle_message(zmq::multipart_t const &message) {
|
||||
print_line("Client handle_message:");
|
||||
print_message_contents(message);
|
||||
NetworkData::MessageType type{ to_message_type(message[0]) };
|
||||
switch (type) {
|
||||
case NetworkData::MSG_OK:
|
||||
|
|
@ -43,11 +41,11 @@ void handle_message(zmq::multipart_t const &message) {
|
|||
handle_ok(message);
|
||||
return;
|
||||
case NetworkData::MSG_HEART:
|
||||
print_line("Client: Received HEART, sending BEAT");
|
||||
multipart(NetworkData::MSG_BEAT).send(*connection->socket);
|
||||
return;
|
||||
default:
|
||||
print_line("Client: Message not handled");
|
||||
print_line("Client: Message not handled:");
|
||||
print_message_contents(message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -132,12 +130,18 @@ void disconnect() {
|
|||
}
|
||||
|
||||
NetworkData::ConnectionStatus status() {
|
||||
return connection ? NetworkData::ConnectionStatus(connection->status) : NetworkData::CONNECTION_DISCONNECTED;
|
||||
if (!connection) {
|
||||
return NetworkData::CONNECTION_DISCONNECTED;
|
||||
} else {
|
||||
std::scoped_lock lock{ connection->mtx };
|
||||
return connection->status;
|
||||
}
|
||||
}
|
||||
|
||||
namespace send {
|
||||
void reveal_clue(NetworkData::ClueID id) {
|
||||
if (connection) {
|
||||
print_line("Sending Clue ", id);
|
||||
std::scoped_lock lock{ connection->mtx };
|
||||
multipart(NetworkData::MSG_REVEAL, id).send(*connection->socket);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue