Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetSession.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | if (m_Host && m_Server) | ||||
enet_peer_disconnect_now(m_Server, NDR_SERVER_SHUTDOWN); | enet_peer_disconnect_now(m_Server, NDR_SERVER_SHUTDOWN); | ||||
enet_host_destroy(m_Host); | enet_host_destroy(m_Host); | ||||
m_Host = NULL; | m_Host = NULL; | ||||
m_Server = NULL; | m_Server = NULL; | ||||
} | } | ||||
} | } | ||||
bool CNetClientSession::Connect(const CStr& server, const u16 port, const bool isLocalClient) | bool CNetClientSession::Connect(const CStr& server, const u16 port, const bool isLocalClient, ENetHost* enetClient) | ||||
{ | { | ||||
ENSURE(!m_Host); | ENSURE(!m_Host); | ||||
ENSURE(!m_Server); | ENSURE(!m_Server); | ||||
// Create ENet host | // Create ENet host | ||||
ENetHost* host = enet_host_create(NULL, 1, CHANNEL_COUNT, 0, 0); | ENetHost* host; | ||||
if (enetClient != NULL) | |||||
host = enetClient; | |||||
else | |||||
host = enet_host_create(NULL, 1, CHANNEL_COUNT, 0, 0); | |||||
if (!host) | if (!host) | ||||
return false; | return false; | ||||
// Bind to specified host | // Bind to specified host | ||||
ENetAddress addr; | ENetAddress addr; | ||||
addr.port = port; | addr.port = port; | ||||
if (enet_address_set_host(&addr, server.c_str()) < 0) | if (enet_address_set_host(&addr, server.c_str()) < 0) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator