diff options
| author | 2017-07-15 11:39:27 +0200 | |
|---|---|---|
| committer | 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.gz yuzu-253d3dd3d889eb61131810b04137ee3f9445db64.tar.xz yuzu-253d3dd3d889eb61131810b04137ee3f9445db64.zip | |
Network: Propagate Room closing to connected members
Diffstat (limited to 'src/network/room.cpp')
| -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: | |||
| 85 | void SendJoinSuccess(ENetPeer* client, MacAddress mac_address); | 85 | void SendJoinSuccess(ENetPeer* client, MacAddress mac_address); |
| 86 | 86 | ||
| 87 | /** | 87 | /** |
| 88 | * Notifies the members that the room is closed, | ||
| 89 | */ | ||
| 90 | void SendCloseMessage(); | ||
| 91 | |||
| 92 | /** | ||
| 88 | * Sends the information about the room, along with the list of members | 93 | * Sends the information about the room, along with the list of members |
| 89 | * to every connected client in the room. | 94 | * to every connected client in the room. |
| 90 | * The packet has the structure: | 95 | * The packet has the structure: |
| @@ -159,6 +164,8 @@ void Room::RoomImpl::ServerLoop() { | |||
| 159 | } | 164 | } |
| 160 | } | 165 | } |
| 161 | } | 166 | } |
| 167 | // Close the connection to all members: | ||
| 168 | SendCloseMessage(); | ||
| 162 | } | 169 | } |
| 163 | 170 | ||
| 164 | void Room::RoomImpl::StartLoop() { | 171 | void Room::RoomImpl::StartLoop() { |
| @@ -266,6 +273,20 @@ void Room::RoomImpl::SendJoinSuccess(ENetPeer* client, MacAddress mac_address) { | |||
| 266 | enet_host_flush(server); | 273 | enet_host_flush(server); |
| 267 | } | 274 | } |
| 268 | 275 | ||
| 276 | void Room::RoomImpl::SendCloseMessage() { | ||
| 277 | Packet packet; | ||
| 278 | packet << static_cast<MessageID>(IdCloseRoom); | ||
| 279 | ENetPacket* enet_packet = | ||
| 280 | enet_packet_create(packet.GetData(), packet.GetDataSize(), ENET_PACKET_FLAG_RELIABLE); | ||
| 281 | for (auto& member : members) { | ||
| 282 | enet_peer_send(member.peer, 0, enet_packet); | ||
| 283 | } | ||
| 284 | enet_host_flush(server); | ||
| 285 | for (auto& member : members) { | ||
| 286 | enet_peer_disconnect(member.peer, 0); | ||
| 287 | } | ||
| 288 | } | ||
| 289 | |||
| 269 | void Room::RoomImpl::BroadcastRoomInformation() { | 290 | void Room::RoomImpl::BroadcastRoomInformation() { |
| 270 | Packet packet; | 291 | Packet packet; |
| 271 | packet << static_cast<MessageID>(IdRoomInformation); | 292 | packet << static_cast<MessageID>(IdRoomInformation); |