diff options
author | B3n30 <benediktthomas@gmail.com> | 2017-07-15 11:39:27 +0200 |
---|---|---|
committer | B3n30 <benediktthomas@gmail.com> | 2017-07-16 21:30:10 +0200 |
commit | 253d3dd3d889eb61131810b04137ee3f9445db64 (patch) | |
tree | 5ff2298ff663de6761425daa1d6943275ee914ea /src/network/room.cpp | |
parent | Network: Made send async in RoomMember (diff) | |
download | yuzu-253d3dd3d889eb61131810b04137ee3f9445db64.tar yuzu-253d3dd3d889eb61131810b04137ee3f9445db64.tar.gz yuzu-253d3dd3d889eb61131810b04137ee3f9445db64.tar.bz2 yuzu-253d3dd3d889eb61131810b04137ee3f9445db64.tar.lz yuzu-253d3dd3d889eb61131810b04137ee3f9445db64.tar.xz yuzu-253d3dd3d889eb61131810b04137ee3f9445db64.tar.zst yuzu-253d3dd3d889eb61131810b04137ee3f9445db64.zip |
Diffstat (limited to '')
-rw-r--r-- | src/network/room.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/network/room.cpp b/src/network/room.cpp index da1679312..3f72d7cbe 100644 --- a/src/network/room.cpp +++ b/src/network/room.cpp @@ -85,6 +85,11 @@ public: void SendJoinSuccess(ENetPeer* client, MacAddress mac_address); /** + * Notifies the members that the room is closed, + */ + void SendCloseMessage(); + + /** * Sends the information about the room, along with the list of members * to every connected client in the room. * The packet has the structure: @@ -159,6 +164,8 @@ void Room::RoomImpl::ServerLoop() { } } } + // Close the connection to all members: + SendCloseMessage(); } void Room::RoomImpl::StartLoop() { @@ -266,6 +273,20 @@ void Room::RoomImpl::SendJoinSuccess(ENetPeer* client, MacAddress mac_address) { enet_host_flush(server); } +void Room::RoomImpl::SendCloseMessage() { + Packet packet; + packet << static_cast<MessageID>(IdCloseRoom); + ENetPacket* enet_packet = + enet_packet_create(packet.GetData(), packet.GetDataSize(), ENET_PACKET_FLAG_RELIABLE); + for (auto& member : members) { + enet_peer_send(member.peer, 0, enet_packet); + } + enet_host_flush(server); + for (auto& member : members) { + enet_peer_disconnect(member.peer, 0); + } +} + void Room::RoomImpl::BroadcastRoomInformation() { Packet packet; packet << static_cast<MessageID>(IdRoomInformation); |