diff options
Diffstat (limited to '')
| -rw-r--r-- | src/network/room_member.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp index e43004027..d6ace9b39 100644 --- a/src/network/room_member.cpp +++ b/src/network/room_member.cpp | |||
| @@ -86,7 +86,7 @@ public: | |||
| 86 | * @params password The password for the room | 86 | * @params password The password for the room |
| 87 | * the server to assign one for us. | 87 | * the server to assign one for us. |
| 88 | */ | 88 | */ |
| 89 | void SendJoinRequest(const std::string& nickname, const std::string& console_id_hash, | 89 | void SendJoinRequest(const std::string& nickname_, const std::string& console_id_hash, |
| 90 | const MacAddress& preferred_mac = NoPreferredMac, | 90 | const MacAddress& preferred_mac = NoPreferredMac, |
| 91 | const std::string& password = "", const std::string& token = ""); | 91 | const std::string& password = "", const std::string& token = ""); |
| 92 | 92 | ||
| @@ -159,7 +159,7 @@ void RoomMember::RoomMemberImpl::MemberLoop() { | |||
| 159 | while (IsConnected()) { | 159 | while (IsConnected()) { |
| 160 | std::lock_guard lock(network_mutex); | 160 | std::lock_guard lock(network_mutex); |
| 161 | ENetEvent event; | 161 | ENetEvent event; |
| 162 | if (enet_host_service(client, &event, 100) > 0) { | 162 | if (enet_host_service(client, &event, 16) > 0) { |
| 163 | switch (event.type) { | 163 | switch (event.type) { |
| 164 | case ENET_EVENT_TYPE_RECEIVE: | 164 | case ENET_EVENT_TYPE_RECEIVE: |
| 165 | switch (event.packet->data[0]) { | 165 | switch (event.packet->data[0]) { |
| @@ -251,16 +251,17 @@ void RoomMember::RoomMemberImpl::MemberLoop() { | |||
| 251 | break; | 251 | break; |
| 252 | } | 252 | } |
| 253 | } | 253 | } |
| 254 | std::list<Packet> packets; | ||
| 254 | { | 255 | { |
| 255 | std::lock_guard lock(send_list_mutex); | 256 | std::lock_guard send_lock(send_list_mutex); |
| 256 | for (const auto& packet : send_list) { | 257 | packets.swap(send_list); |
| 257 | ENetPacket* enetPacket = enet_packet_create(packet.GetData(), packet.GetDataSize(), | 258 | } |
| 258 | ENET_PACKET_FLAG_RELIABLE); | 259 | for (const auto& packet : packets) { |
| 259 | enet_peer_send(server, 0, enetPacket); | 260 | ENetPacket* enetPacket = enet_packet_create(packet.GetData(), packet.GetDataSize(), |
| 260 | } | 261 | ENET_PACKET_FLAG_RELIABLE); |
| 261 | enet_host_flush(client); | 262 | enet_peer_send(server, 0, enetPacket); |
| 262 | send_list.clear(); | ||
| 263 | } | 263 | } |
| 264 | enet_host_flush(client); | ||
| 264 | } | 265 | } |
| 265 | Disconnect(); | 266 | Disconnect(); |
| 266 | }; | 267 | }; |
| @@ -274,14 +275,14 @@ void RoomMember::RoomMemberImpl::Send(Packet&& packet) { | |||
| 274 | send_list.push_back(std::move(packet)); | 275 | send_list.push_back(std::move(packet)); |
| 275 | } | 276 | } |
| 276 | 277 | ||
| 277 | void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname, | 278 | void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname_, |
| 278 | const std::string& console_id_hash, | 279 | const std::string& console_id_hash, |
| 279 | const MacAddress& preferred_mac, | 280 | const MacAddress& preferred_mac, |
| 280 | const std::string& password, | 281 | const std::string& password, |
| 281 | const std::string& token) { | 282 | const std::string& token) { |
| 282 | Packet packet; | 283 | Packet packet; |
| 283 | packet << static_cast<u8>(IdJoinRequest); | 284 | packet << static_cast<u8>(IdJoinRequest); |
| 284 | packet << nickname; | 285 | packet << nickname_; |
| 285 | packet << console_id_hash; | 286 | packet << console_id_hash; |
| 286 | packet << preferred_mac; | 287 | packet << preferred_mac; |
| 287 | packet << network_version; | 288 | packet << network_version; |