mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
e149ad4f0a
SPDX standardizes how source code conveys its copyright and licensing information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX tags are adopted in many large projects, including things like the Linux kernel.
39 lines
1011 B
C++
39 lines
1011 B
C++
// Copyright 2015 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "ENetUtil.h"
|
|
|
|
#include "Common/CommonTypes.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;
|
|
}
|
|
} // namespace ENetUtil
|