diff options
author | B3n30 <bene_thomas@web.de> | 2017-08-19 19:14:33 +0200 |
---|---|---|
committer | James Rowe <jroweboy@gmail.com> | 2017-08-19 19:14:33 +0200 |
commit | 5d0a1e7efddf234234d54fe97395f6975f8d1a28 (patch) | |
tree | cef0c9114f39af64c2971509fb2d0197c73cc155 /src/network/room_member.h | |
parent | Merge pull request #2881 from MerryMage/dsp-firm-check (diff) | |
download | yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.gz yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.bz2 yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.lz yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.xz yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.zst yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.zip |
Diffstat (limited to 'src/network/room_member.h')
-rw-r--r-- | src/network/room_member.h | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/src/network/room_member.h b/src/network/room_member.h index bc1af3a7e..98770a234 100644 --- a/src/network/room_member.h +++ b/src/network/room_member.h @@ -4,6 +4,7 @@ #pragma once +#include <functional> #include <memory> #include <string> #include <vector> @@ -53,12 +54,23 @@ public: struct MemberInformation { std::string nickname; ///< Nickname of the member. - std::string game_name; ///< Name of the game they're currently playing, or empty if they're + GameInfo game_info; ///< Name of the game they're currently playing, or empty if they're /// not playing anything. MacAddress mac_address; ///< MAC address associated with this member. }; using MemberList = std::vector<MemberInformation>; + // The handle for the callback functions + template <typename T> + using CallbackHandle = std::shared_ptr<std::function<void(const T&)>>; + + /** + * Unbinds a callback function from the events. + * @param handle The connection handle to disconnect + */ + template <typename T> + void Unbind(CallbackHandle<T> handle); + RoomMember(); ~RoomMember(); @@ -113,10 +125,49 @@ public: void SendChatMessage(const std::string& message); /** - * Sends the current game name to the room. - * @param game_name The game name. + * Sends the current game info to the room. + * @param game_info The game information. + */ + void SendGameInfo(const GameInfo& game_info); + + /** + * Binds a function to an event that will be triggered every time the State of the member + * changed. The function wil be called every time the event is triggered. The callback function + * must not bind or unbind a function. Doing so will cause a deadlock + * @param callback The function to call + * @return A handle used for removing the function from the registered list + */ + CallbackHandle<State> BindOnStateChanged(std::function<void(const State&)> callback); + + /** + * Binds a function to an event that will be triggered every time a WifiPacket is received. + * The function wil be called everytime the event is triggered. + * The callback function must not bind or unbind a function. Doing so will cause a deadlock + * @param callback The function to call + * @return A handle used for removing the function from the registered list + */ + CallbackHandle<WifiPacket> BindOnWifiPacketReceived( + std::function<void(const WifiPacket&)> callback); + + /** + * Binds a function to an event that will be triggered every time the RoomInformation changes. + * The function wil be called every time the event is triggered. + * The callback function must not bind or unbind a function. Doing so will cause a deadlock + * @param callback The function to call + * @return A handle used for removing the function from the registered list + */ + CallbackHandle<RoomInformation> BindOnRoomInformationChanged( + std::function<void(const RoomInformation&)> callback); + + /** + * Binds a function to an event that will be triggered every time a ChatMessage is received. + * The function wil be called every time the event is triggered. + * The callback function must not bind or unbind a function. Doing so will cause a deadlock + * @param callback The function to call + * @return A handle used for removing the function from the registered list */ - void SendGameName(const std::string& game_name); + CallbackHandle<ChatEntry> BindOnChatMessageRecieved( + std::function<void(const ChatEntry&)> callback); /** * Leaves the current room. |