Network: Enable to send WifiPackets
This commit is contained in:
parent
ebff5ba514
commit
641346c15c
3 changed files with 82 additions and 1 deletions
|
@ -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>()} {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue