diff options
| author | Dolphin Bot <dolphin-emu-bot@users.noreply.github.com> | 2015-03-18 11:36:08 +0100 |
|---|---|---|
| committer | Dolphin Bot <dolphin-emu-bot@users.noreply.github.com> | 2015-03-18 11:36:08 +0100 |
| commit | 486370829a95e2b9e21cfda701be337508c2dd2a (patch) | |
| tree | 638729fa0539fbd0d6e622c1b9aa88ef4d71df6b /Source/Core/Common/ENetUtil.cpp | |
| parent | 27619e613ffffb6e3c3d21b59a97b51107994acb (diff) | |
| parent | 8201a52cec975c6ed9c81bd6f33c41b3ef7b473a (diff) | |
Merge pull request #2198 from mathieui/netplay-threading-fix
Fix netplay threading issues
Diffstat (limited to 'Source/Core/Common/ENetUtil.cpp')
| -rw-r--r-- | Source/Core/Common/ENetUtil.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/Core/Common/ENetUtil.cpp b/Source/Core/Common/ENetUtil.cpp new file mode 100644 index 0000000000..ae5b19b2c3 --- /dev/null +++ b/Source/Core/Common/ENetUtil.cpp @@ -0,0 +1,40 @@ +// 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); +} + +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; +} + + +} |
