diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-03 17:03:59 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-03 17:03:59 +0200 |
commit | f7decf41d8d0062901cd39c42a3669a80537c7df (patch) | |
tree | d3032265df11eee6e3eaf8b4b081524bef5e72b2 /src/Event.hpp | |
parent | 2017-07-29 (diff) | |
download | AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.gz AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.bz2 AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.lz AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.xz AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.zst AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Event.hpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/Event.hpp b/src/Event.hpp index 2d830a4..229da19 100644 --- a/src/Event.hpp +++ b/src/Event.hpp @@ -19,8 +19,10 @@ enum class EventType { ConnectionSuccessfull, GlobalAppState, Disconnect, - SendPacket, - ReceivePacket, + RequestNetworkClient, + RegisterNetworkClient, + PlayerConnected, + RemoveLoadingScreen, }; struct EchoData { @@ -36,8 +38,10 @@ struct ConnectToServerData { unsigned short port; }; -struct ConnectionSuccessfullData { +class NetworkClient; +struct ConnectionSuccessfullData { + NetworkClient *ptr; }; enum class GlobalState { @@ -65,8 +69,27 @@ struct ReceivePacketData { std::shared_ptr<Packet> packet; }; +struct RequestNetworkClientData { + +}; + +struct RegisterNetworkClientData { + NetworkClient *ptr; +}; + +class GameState; + +struct PlayerConnectedData { + GameState *ptr; +}; + +struct RemoveLoadingScreenData { + +}; + using EventData = std::variant<EchoData, ChunkChangedData, ConnectToServerData, ConnectionSuccessfullData, - GlobalAppStateData, DisconnectData, SendPacketData, ReceivePacketData>; + GlobalAppStateData, DisconnectData, SendPacketData, ReceivePacketData, RequestNetworkClientData, + RegisterNetworkClientData, PlayerConnectedData, RemoveLoadingScreenData>; struct Event { EventType type; @@ -80,10 +103,12 @@ class EventListener { std::map<EventType, HandlerFunc> handlers; //TODO: There must be more elegant solution than std::variant of all data - std::mutex eventsMutex; + std::mutex handlersMutex; std::queue<Event> events; + std::mutex eventsMutex; + void PushEvent(Event event); public: |