Commit 6119869f authored by Hubert Denkmair's avatar Hubert Denkmair

fix tick message

parent 4576512a
......@@ -123,7 +123,9 @@ int RelayServer::Run()
res->end(response.data(), response.length());
});
if (!h.listen(atoi(websocketPort)))
auto listenPort = atoi(websocketPort);
fprintf(stderr, "listening on port %d...\n", listenPort);
if (!h.listen(listenPort))
{
return -1;
}
......
......@@ -101,8 +101,7 @@ void TcpProtocol::OnMessageReceived(const char* data, size_t count)
case MsgPackProtocol::MESSAGE_TYPE_TICK:
{
auto msg = std::make_unique<MsgPackProtocol::TickMessage>();
OnTickReceived(std::move(msg));
OnTickReceived(obj.get().as<MsgPackProtocol::TickMessage>());
break;
}
......@@ -180,13 +179,12 @@ void TcpProtocol::OnWorldUpdateReceived(const MsgPackProtocol::WorldUpdateMessag
}
}
void TcpProtocol::OnTickReceived(std::unique_ptr<MsgPackProtocol::TickMessage> msg)
void TcpProtocol::OnTickReceived(const MsgPackProtocol::TickMessage& msg)
{
auto frame_id = msg->frame_id;
_pendingMessages.push_back(std::move(msg));
_pendingMessages.push_back(std::make_unique<MsgPackProtocol::TickMessage>(msg));
if (_frameCompleteCallback!=nullptr)
{
_frameCompleteCallback(frame_id);
_frameCompleteCallback(msg.frame_id);
}
_pendingMessages.clear();
}
......
......@@ -51,7 +51,7 @@ class TcpProtocol
void OnGameInfoReceived(const MsgPackProtocol::GameInfoMessage& msg);
void OnWorldUpdateReceived(const MsgPackProtocol::WorldUpdateMessage& msg);
void OnTickReceived(std::unique_ptr<MsgPackProtocol::TickMessage> msg);
void OnTickReceived(const MsgPackProtocol::TickMessage &msg);
void OnFoodSpawnReceived(const MsgPackProtocol::FoodSpawnMessage& msg);
void OnFoodConsumedReceived(const MsgPackProtocol::FoodConsumeMessage& msg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment