diff options
Diffstat (limited to 'src/Event.hpp')
-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: |