summaryrefslogtreecommitdiff
path: root/src/network/room_member.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/room_member.h')
-rw-r--r--src/network/room_member.h59
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 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <functional>
7#include <memory> 8#include <memory>
8#include <string> 9#include <string>
9#include <vector> 10#include <vector>
@@ -53,12 +54,23 @@ public:
53 54
54 struct MemberInformation { 55 struct MemberInformation {
55 std::string nickname; ///< Nickname of the member. 56 std::string nickname; ///< Nickname of the member.
56 std::string game_name; ///< Name of the game they're currently playing, or empty if they're 57 GameInfo game_info; ///< Name of the game they're currently playing, or empty if they're
57 /// not playing anything. 58 /// not playing anything.
58 MacAddress mac_address; ///< MAC address associated with this member. 59 MacAddress mac_address; ///< MAC address associated with this member.
59 }; 60 };
60 using MemberList = std::vector<MemberInformation>; 61 using MemberList = std::vector<MemberInformation>;
61 62
63 // The handle for the callback functions
64 template <typename T>
65 using CallbackHandle = std::shared_ptr<std::function<void(const T&)>>;
66
67 /**
68 * Unbinds a callback function from the events.
69 * @param handle The connection handle to disconnect
70 */
71 template <typename T>
72 void Unbind(CallbackHandle<T> handle);
73
62 RoomMember(); 74 RoomMember();
63 ~RoomMember(); 75 ~RoomMember();
64 76
@@ -113,10 +125,49 @@ public:
113 void SendChatMessage(const std::string& message); 125 void SendChatMessage(const std::string& message);
114 126
115 /** 127 /**
116 * Sends the current game name to the room. 128 * Sends the current game info to the room.
117 * @param game_name The game name. 129 * @param game_info The game information.
130 */
131 void SendGameInfo(const GameInfo& game_info);
132
133 /**
134 * Binds a function to an event that will be triggered every time the State of the member
135 * changed. The function wil be called every time the event is triggered. The callback function
136 * must not bind or unbind a function. Doing so will cause a deadlock
137 * @param callback The function to call
138 * @return A handle used for removing the function from the registered list
139 */
140 CallbackHandle<State> BindOnStateChanged(std::function<void(const State&)> callback);
141
142 /**
143 * Binds a function to an event that will be triggered every time a WifiPacket is received.
144 * The function wil be called everytime the event is triggered.
145 * The callback function must not bind or unbind a function. Doing so will cause a deadlock
146 * @param callback The function to call
147 * @return A handle used for removing the function from the registered list
148 */
149 CallbackHandle<WifiPacket> BindOnWifiPacketReceived(
150 std::function<void(const WifiPacket&)> callback);
151
152 /**
153 * Binds a function to an event that will be triggered every time the RoomInformation changes.
154 * The function wil be called every time the event is triggered.
155 * The callback function must not bind or unbind a function. Doing so will cause a deadlock
156 * @param callback The function to call
157 * @return A handle used for removing the function from the registered list
158 */
159 CallbackHandle<RoomInformation> BindOnRoomInformationChanged(
160 std::function<void(const RoomInformation&)> callback);
161
162 /**
163 * Binds a function to an event that will be triggered every time a ChatMessage is received.
164 * The function wil be called every time the event is triggered.
165 * The callback function must not bind or unbind a function. Doing so will cause a deadlock
166 * @param callback The function to call
167 * @return A handle used for removing the function from the registered list
118 */ 168 */
119 void SendGameName(const std::string& game_name); 169 CallbackHandle<ChatEntry> BindOnChatMessageRecieved(
170 std::function<void(const ChatEntry&)> callback);
120 171
121 /** 172 /**
122 * Leaves the current room. 173 * Leaves the current room.