2015-03-09 11:37:02 -06:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2015-03-09 11:37:02 -06:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "ENetUtil.h"
|
|
|
|
|
2015-05-10 19:16:05 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2015-03-09 11:37:02 -06:00
|
|
|
namespace ENetUtil
|
|
|
|
{
|
|
|
|
void WakeupThread(ENetHost* host)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// 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);
|
2015-03-09 11:37:02 -06:00
|
|
|
}
|
|
|
|
|
2015-03-14 08:19:18 -06:00
|
|
|
int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// wakeup packet received
|
|
|
|
if (host->receivedDataLength == 1 && host->receivedData[0] == 0)
|
|
|
|
{
|
|
|
|
event->type = (ENetEventType)42;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2015-03-14 08:19:18 -06:00
|
|
|
}
|
2015-03-09 11:37:02 -06:00
|
|
|
}
|