summaryrefslogtreecommitdiff
path: root/src/network/room.cpp
diff options
context:
space:
mode:
authorGravatar B3n302017-07-09 10:40:11 +0200
committerGravatar B3n302017-07-16 21:29:34 +0200
commit641346c15c0091d59259f6acc5f8789efe16c937 (patch)
treedb87a00159c0feb35bb663b2e49ca8348451e4fe /src/network/room.cpp
parentNetwork: Init Network in SDL and QT (diff)
downloadyuzu-641346c15c0091d59259f6acc5f8789efe16c937.tar.gz
yuzu-641346c15c0091d59259f6acc5f8789efe16c937.tar.xz
yuzu-641346c15c0091d59259f6acc5f8789efe16c937.zip
Network: Enable to send WifiPackets
Diffstat (limited to 'src/network/room.cpp')
-rw-r--r--src/network/room.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/network/room.cpp b/src/network/room.cpp
index 3502264e1..3caa3aeae 100644
--- a/src/network/room.cpp
+++ b/src/network/room.cpp
@@ -98,6 +98,12 @@ public:
98 * The first 3 bytes are the NintendoOUI 0x00, 0x1F, 0x32 98 * The first 3 bytes are the NintendoOUI 0x00, 0x1F, 0x32
99 */ 99 */
100 MacAddress GenerateMacAddress(); 100 MacAddress GenerateMacAddress();
101
102 /**
103 * Broadcasts this packet to all members except the sender.
104 * @param event The ENet event containing the data
105 */
106 void HandleWifiPacket(const ENetEvent* event);
101}; 107};
102 108
103// RoomImpl 109// RoomImpl
@@ -111,7 +117,10 @@ void Room::RoomImpl::ServerLoop() {
111 case IdJoinRequest: 117 case IdJoinRequest:
112 HandleJoinRequest(&event); 118 HandleJoinRequest(&event);
113 break; 119 break;
114 // TODO(B3N30): Handle the other message types 120 // TODO(B3N30): Handle the other message types
121 case IdWifiPacket:
122 HandleWifiPacket(&event);
123 break;
115 } 124 }
116 enet_packet_destroy(event.packet); 125 enet_packet_destroy(event.packet);
117 break; 126 break;
@@ -247,6 +256,14 @@ MacAddress Room::RoomImpl::GenerateMacAddress() {
247 return result_mac; 256 return result_mac;
248} 257}
249 258
259void Room::RoomImpl::HandleWifiPacket(const ENetEvent* event) {
260 for (auto it = members.begin(); it != members.end(); ++it) {
261 if (it->peer != event->peer)
262 enet_peer_send(it->peer, 0, event->packet);
263 }
264 enet_host_flush(server);
265}
266
250// Room 267// Room
251Room::Room() : room_impl{std::make_unique<RoomImpl>()} {} 268Room::Room() : room_impl{std::make_unique<RoomImpl>()} {}
252 269