diff options
Diffstat (limited to 'src/GlobalState.cpp')
-rw-r--r-- | src/GlobalState.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/GlobalState.cpp b/src/GlobalState.cpp index f04bb35..57b42ea 100644 --- a/src/GlobalState.cpp +++ b/src/GlobalState.cpp @@ -64,6 +64,11 @@ void InitEvents() { PUSH_EVENT("Disconnect", data); }); + listener.RegisterHandler("ReceivedPacket", [](const Event& eventData) { + std::shared_ptr<Packet> packet = eventData.get<std::shared_ptr<Packet>>(); + gs->UpdatePacket(packet); + }); + /* * GameState Events */ @@ -88,7 +93,8 @@ void InitEvents() { listener.RegisterHandler("SendChatMessage", [](const Event& eventData) { auto message = eventData.get<std::string>(); - nc->SendPacket(std::make_shared<PacketChatMessageSB>(message)); + auto packet = std::static_pointer_cast<Packet>(std::make_shared<PacketChatMessageSB>(message)); + PUSH_EVENT("SendPacket",packet); }); } @@ -183,9 +189,6 @@ void GsExec() { while (isRunning) { try { while (nc && gs) { - nc->UpdatePacket(); - - gs->UpdatePacket(nc.get()); listener.HandleAllEvents(); } } catch (std::exception &e) { |