diff options
| author | 2022-07-31 04:46:26 +0200 | |
|---|---|---|
| committer | 2022-09-09 14:30:22 +0200 | |
| commit | f5e635addaef59159bf6bc529b17954eda3684a1 (patch) | |
| tree | 6d6b518611b377b6bd79e3156eb16f60f5045698 /src/network/room_member.h | |
| parent | Merge pull request #8819 from liamwhite/cash-money (diff) | |
| download | yuzu-f5e635addaef59159bf6bc529b17954eda3684a1.tar.gz yuzu-f5e635addaef59159bf6bc529b17954eda3684a1.tar.xz yuzu-f5e635addaef59159bf6bc529b17954eda3684a1.zip | |
ldn: Initial implementation
Diffstat (limited to 'src/network/room_member.h')
| -rw-r--r-- | src/network/room_member.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/network/room_member.h b/src/network/room_member.h index f578f7f6a..0d6417294 100644 --- a/src/network/room_member.h +++ b/src/network/room_member.h | |||
| @@ -17,7 +17,24 @@ namespace Network { | |||
| 17 | using AnnounceMultiplayerRoom::GameInfo; | 17 | using AnnounceMultiplayerRoom::GameInfo; |
| 18 | using AnnounceMultiplayerRoom::RoomInformation; | 18 | using AnnounceMultiplayerRoom::RoomInformation; |
| 19 | 19 | ||
| 20 | /// Information about the received WiFi packets. | 20 | enum class LDNPacketType : u8 { |
| 21 | Scan, | ||
| 22 | ScanResp, | ||
| 23 | Connect, | ||
| 24 | SyncNetwork, | ||
| 25 | Disconnect, | ||
| 26 | DestroyNetwork, | ||
| 27 | }; | ||
| 28 | |||
| 29 | struct LDNPacket { | ||
| 30 | LDNPacketType type; | ||
| 31 | IPv4Address local_ip; | ||
| 32 | IPv4Address remote_ip; | ||
| 33 | bool broadcast; | ||
| 34 | std::vector<u8> data; | ||
| 35 | }; | ||
| 36 | |||
| 37 | /// Information about the received proxy packets. | ||
| 21 | struct ProxyPacket { | 38 | struct ProxyPacket { |
| 22 | SockAddrIn local_endpoint; | 39 | SockAddrIn local_endpoint; |
| 23 | SockAddrIn remote_endpoint; | 40 | SockAddrIn remote_endpoint; |
| @@ -152,6 +169,12 @@ public: | |||
| 152 | void SendProxyPacket(const ProxyPacket& packet); | 169 | void SendProxyPacket(const ProxyPacket& packet); |
| 153 | 170 | ||
| 154 | /** | 171 | /** |
| 172 | * Sends an LDN packet to the room. | ||
| 173 | * @param packet The WiFi packet to send. | ||
| 174 | */ | ||
| 175 | void SendLdnPacket(const LDNPacket& packet); | ||
| 176 | |||
| 177 | /** | ||
| 155 | * Sends a chat message to the room. | 178 | * Sends a chat message to the room. |
| 156 | * @param message The contents of the message. | 179 | * @param message The contents of the message. |
| 157 | */ | 180 | */ |
| @@ -205,6 +228,16 @@ public: | |||
| 205 | std::function<void(const ProxyPacket&)> callback); | 228 | std::function<void(const ProxyPacket&)> callback); |
| 206 | 229 | ||
| 207 | /** | 230 | /** |
| 231 | * Binds a function to an event that will be triggered every time an LDNPacket is received. | ||
| 232 | * The function wil be called everytime the event is triggered. | ||
| 233 | * The callback function must not bind or unbind a function. Doing so will cause a deadlock | ||
| 234 | * @param callback The function to call | ||
| 235 | * @return A handle used for removing the function from the registered list | ||
| 236 | */ | ||
| 237 | CallbackHandle<LDNPacket> BindOnLdnPacketReceived( | ||
| 238 | std::function<void(const LDNPacket&)> callback); | ||
| 239 | |||
| 240 | /** | ||
| 208 | * Binds a function to an event that will be triggered every time the RoomInformation changes. | 241 | * Binds a function to an event that will be triggered every time the RoomInformation changes. |
| 209 | * The function wil be called every time the event is triggered. | 242 | * The function wil be called every time the event is triggered. |
| 210 | * The callback function must not bind or unbind a function. Doing so will cause a deadlock | 243 | * The callback function must not bind or unbind a function. Doing so will cause a deadlock |