mirror of
https://github.com/citra-mirror/citra.git
synced 2024-08-19 01:53:22 +02:00
reduce network latency
This commit is contained in:
parent
b7f0e886d9
commit
adac0d193b
@ -251,7 +251,7 @@ public:
|
||||
void Room::RoomImpl::ServerLoop() {
|
||||
while (state != State::Closed) {
|
||||
ENetEvent event;
|
||||
if (enet_host_service(server, &event, 50) > 0) {
|
||||
if (enet_host_service(server, &event, 16) > 0) {
|
||||
switch (event.type) {
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
switch (event.packet->data[0]) {
|
||||
|
@ -159,7 +159,7 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
|
||||
while (IsConnected()) {
|
||||
std::lock_guard lock(network_mutex);
|
||||
ENetEvent event;
|
||||
if (enet_host_service(client, &event, 100) > 0) {
|
||||
if (enet_host_service(client, &event, 16) > 0) {
|
||||
switch (event.type) {
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
switch (event.packet->data[0]) {
|
||||
@ -251,16 +251,18 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::list<Packet> packets;
|
||||
{
|
||||
std::lock_guard lock(send_list_mutex);
|
||||
for (const auto& packet : send_list) {
|
||||
ENetPacket* enetPacket = enet_packet_create(packet.GetData(), packet.GetDataSize(),
|
||||
ENET_PACKET_FLAG_RELIABLE);
|
||||
enet_peer_send(server, 0, enetPacket);
|
||||
}
|
||||
enet_host_flush(client);
|
||||
send_list.clear();
|
||||
packets.swap(send_list);
|
||||
}
|
||||
for (const auto& packet : packets) {
|
||||
ENetPacket* enetPacket = enet_packet_create(packet.GetData(), packet.GetDataSize(),
|
||||
ENET_PACKET_FLAG_RELIABLE);
|
||||
enet_peer_send(server, 0, enetPacket);
|
||||
}
|
||||
enet_host_flush(client);
|
||||
}
|
||||
Disconnect();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user