From 44d7207a1c288f216c4d1fa517b8fb0aa94bc001 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 9 Mar 2015 18:37:02 +0100 Subject: NetPlay: add a Common/ENetUtil namespace Move WakeupThread in it --- Source/Core/Common/ENetUtil.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Source/Core/Common/ENetUtil.cpp (limited to 'Source/Core/Common/ENetUtil.cpp') diff --git a/Source/Core/Common/ENetUtil.cpp b/Source/Core/Common/ENetUtil.cpp new file mode 100644 index 0000000000..7269893f90 --- /dev/null +++ b/Source/Core/Common/ENetUtil.cpp @@ -0,0 +1,28 @@ +// Copyright 2015 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include "ENetUtil.h" + +namespace ENetUtil +{ + +void WakeupThread(ENetHost* host) +{ + // Send ourselves a spurious message. This is hackier than it should be. + // comex reported this as https://github.com/lsalzman/enet/issues/23, so + // hopefully there will be a better way to do it in the future. + ENetAddress address; + if (host->address.port != 0) + address.port = host->address.port; + else + enet_socket_get_address(host->socket, &address); + address.host = 0x0100007f; // localhost + u8 byte = 0; + ENetBuffer buf; + buf.data = &byte; + buf.dataLength = 1; + enet_socket_send(host->socket, &address, &buf, 1); +} + +} -- cgit v1.2.3 From e0ef8fc03f1fafc801ca5d857347f9fa1ea58881 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 14 Mar 2015 15:19:18 +0100 Subject: NetPlay: Make the enet interrupts work Otherwise, it would work but any async sending would be delayed by 4ms or wait until the next packet was received. Also increase the client timeout to 250ms, since enet_host_service is now really interrupted. --- Source/Core/Common/ENetUtil.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Source/Core/Common/ENetUtil.cpp') diff --git a/Source/Core/Common/ENetUtil.cpp b/Source/Core/Common/ENetUtil.cpp index 7269893f90..ae5b19b2c3 100644 --- a/Source/Core/Common/ENetUtil.cpp +++ b/Source/Core/Common/ENetUtil.cpp @@ -25,4 +25,16 @@ void WakeupThread(ENetHost* host) enet_socket_send(host->socket, &address, &buf, 1); } +int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event) +{ + // wakeup packet received + if (host->receivedDataLength == 1 && host->receivedData[0] == 0) + { + event->type = (ENetEventType) 42; + return 1; + } + return 0; +} + + } -- cgit v1.2.3 From 379f9feebd6d9375fdb0d8cc2b40f5229f55fe4a Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 10 May 2015 20:16:05 -0500 Subject: Fix non-PCH build. --- Source/Core/Common/ENetUtil.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Source/Core/Common/ENetUtil.cpp') diff --git a/Source/Core/Common/ENetUtil.cpp b/Source/Core/Common/ENetUtil.cpp index ae5b19b2c3..8cfb36e7e0 100644 --- a/Source/Core/Common/ENetUtil.cpp +++ b/Source/Core/Common/ENetUtil.cpp @@ -4,6 +4,8 @@ #include "ENetUtil.h" +#include "Common/CommonTypes.h" + namespace ENetUtil { -- cgit v1.2.3 From cefcb0ace9d363b3679b4e93bcc9ec05f1e5f4f8 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Mon, 18 May 2015 01:08:10 +0200 Subject: Update license headers to GPLv2+ --- Source/Core/Common/ENetUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common/ENetUtil.cpp') diff --git a/Source/Core/Common/ENetUtil.cpp b/Source/Core/Common/ENetUtil.cpp index 8cfb36e7e0..365d69b04e 100644 --- a/Source/Core/Common/ENetUtil.cpp +++ b/Source/Core/Common/ENetUtil.cpp @@ -1,5 +1,5 @@ // Copyright 2015 Dolphin Emulator Project -// Licensed under GPLv2 +// Licensed under GPLv2+ // Refer to the license.txt file included. #include "ENetUtil.h" -- cgit v1.2.3