diff options
author | B3n30 <benediktthomas@gmail.com> | 2017-07-09 10:40:11 +0200 |
---|---|---|
committer | B3n30 <benediktthomas@gmail.com> | 2017-07-16 21:29:34 +0200 |
commit | 641346c15c0091d59259f6acc5f8789efe16c937 (patch) | |
tree | db87a00159c0feb35bb663b2e49ca8348451e4fe /src/network/room.cpp | |
parent | Network: Init Network in SDL and QT (diff) | |
download | yuzu-641346c15c0091d59259f6acc5f8789efe16c937.tar yuzu-641346c15c0091d59259f6acc5f8789efe16c937.tar.gz yuzu-641346c15c0091d59259f6acc5f8789efe16c937.tar.bz2 yuzu-641346c15c0091d59259f6acc5f8789efe16c937.tar.lz yuzu-641346c15c0091d59259f6acc5f8789efe16c937.tar.xz yuzu-641346c15c0091d59259f6acc5f8789efe16c937.tar.zst yuzu-641346c15c0091d59259f6acc5f8789efe16c937.zip |
Diffstat (limited to '')
-rw-r--r-- | src/network/room.cpp | 19 |
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: * The first 3 bytes are the NintendoOUI 0x00, 0x1F, 0x32 */ MacAddress GenerateMacAddress(); + + /** + * Broadcasts this packet to all members except the sender. + * @param event The ENet event containing the data + */ + void HandleWifiPacket(const ENetEvent* event); }; // RoomImpl @@ -111,7 +117,10 @@ void Room::RoomImpl::ServerLoop() { case IdJoinRequest: HandleJoinRequest(&event); break; - // TODO(B3N30): Handle the other message types + // TODO(B3N30): Handle the other message types + case IdWifiPacket: + HandleWifiPacket(&event); + break; } enet_packet_destroy(event.packet); break; @@ -247,6 +256,14 @@ MacAddress Room::RoomImpl::GenerateMacAddress() { return result_mac; } +void Room::RoomImpl::HandleWifiPacket(const ENetEvent* event) { + for (auto it = members.begin(); it != members.end(); ++it) { + if (it->peer != event->peer) + enet_peer_send(it->peer, 0, event->packet); + } + enet_host_flush(server); +} + // Room Room::Room() : room_impl{std::make_unique<RoomImpl>()} {} |