Compare commits
2 Commits
7ea90b03c4
...
9a63cf868d
Author | SHA1 | Date |
---|---|---|
Mr_Goldberg | 9a63cf868d | |
Mr_Goldberg | 37b329c9c5 |
|
@ -107,11 +107,16 @@ Steam_Networking_Sockets(class Settings *settings, class Networking *network, cl
|
||||||
this->run_every_runcb->remove(&Steam_Networking_Sockets::steam_run_every_runcb, this);
|
this->run_every_runcb->remove(&Steam_Networking_Sockets::steam_run_every_runcb, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned long get_socket_id()
|
||||||
|
{
|
||||||
|
static unsigned long socket_id;
|
||||||
|
socket_id++;
|
||||||
|
return socket_id;
|
||||||
|
}
|
||||||
|
|
||||||
HSteamListenSocket new_listen_socket(int nSteamConnectVirtualPort)
|
HSteamListenSocket new_listen_socket(int nSteamConnectVirtualPort)
|
||||||
{
|
{
|
||||||
static HSteamListenSocket socket_id;
|
HSteamListenSocket socket_id = get_socket_id();
|
||||||
++socket_id;
|
|
||||||
if (socket_id == k_HSteamListenSocket_Invalid) ++socket_id;
|
if (socket_id == k_HSteamListenSocket_Invalid) ++socket_id;
|
||||||
|
|
||||||
auto conn = std::find_if(listen_sockets.begin(), listen_sockets.end(), [&nSteamConnectVirtualPort](struct Listen_Socket const& conn) { return conn.virtual_port == nSteamConnectVirtualPort;});
|
auto conn = std::find_if(listen_sockets.begin(), listen_sockets.end(), [&nSteamConnectVirtualPort](struct Listen_Socket const& conn) { return conn.virtual_port == nSteamConnectVirtualPort;});
|
||||||
|
@ -165,8 +170,7 @@ HSteamNetConnection new_connect_socket(SteamNetworkingIdentity remote_identity,
|
||||||
socket.user_data = -1;
|
socket.user_data = -1;
|
||||||
socket.poll_group = k_HSteamNetPollGroup_Invalid;
|
socket.poll_group = k_HSteamNetPollGroup_Invalid;
|
||||||
|
|
||||||
static HSteamNetConnection socket_id;
|
HSteamNetConnection socket_id = get_socket_id();
|
||||||
++socket_id;
|
|
||||||
if (socket_id == k_HSteamNetConnection_Invalid) ++socket_id;
|
if (socket_id == k_HSteamNetConnection_Invalid) ++socket_id;
|
||||||
|
|
||||||
if (connect_sockets.insert(std::make_pair(socket_id, socket)).second == false) {
|
if (connect_sockets.insert(std::make_pair(socket_id, socket)).second == false) {
|
||||||
|
@ -833,7 +837,25 @@ int ReceiveMessagesOnListenSocket( HSteamListenSocket hSocket, SteamNetworkingMe
|
||||||
bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo_t *pInfo )
|
bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo_t *pInfo )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("Steam_Networking_Sockets::GetConnectionInfo\n");
|
PRINT_DEBUG("Steam_Networking_Sockets::GetConnectionInfo\n");
|
||||||
|
if (!pInfo)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
|
auto connect_socket = connect_sockets.find(hConn);
|
||||||
|
if (connect_socket == connect_sockets.end()) return false;
|
||||||
|
|
||||||
|
memset(pInfo, 0, sizeof(SteamNetConnectionInfo_t));
|
||||||
|
pInfo->m_identityRemote = connect_socket->second.remote_identity;
|
||||||
|
pInfo->m_nUserData = connect_socket->second.user_data;
|
||||||
|
pInfo->m_hListenSocket = connect_socket->second.listen_socket_id;
|
||||||
|
//pInfo->m_addrRemote; //TODO
|
||||||
|
pInfo->m_idPOPRemote = 0;
|
||||||
|
pInfo->m_idPOPRelay = 0;
|
||||||
|
pInfo->m_eState = convert_status(connect_socket->second.status);
|
||||||
|
pInfo->m_eEndReason = 0; //TODO
|
||||||
|
pInfo->m_szEndDebug[0] = 0;
|
||||||
|
sprintf(pInfo->m_szConnectionDescription, "%u", hConn);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -878,7 +900,7 @@ int ReceiveMessagesOnListenSocket( HSteamListenSocket hSocket, SteamNetworkingMe
|
||||||
/// Returns information about the specified connection.
|
/// Returns information about the specified connection.
|
||||||
bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo001_t *pInfo )
|
bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo001_t *pInfo )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("Steam_Networking_Sockets::GetConnectionInfo\n");
|
PRINT_DEBUG("Steam_Networking_Sockets::GetConnectionInfo001\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,7 +910,21 @@ bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo001_t *
|
||||||
bool GetQuickConnectionStatus( HSteamNetConnection hConn, SteamNetworkingQuickConnectionStatus *pStats )
|
bool GetQuickConnectionStatus( HSteamNetConnection hConn, SteamNetworkingQuickConnectionStatus *pStats )
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("Steam_Networking_Sockets::GetQuickConnectionStatus\n");
|
PRINT_DEBUG("Steam_Networking_Sockets::GetQuickConnectionStatus\n");
|
||||||
|
if (!pStats)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
|
auto connect_socket = connect_sockets.find(hConn);
|
||||||
|
if (connect_socket == connect_sockets.end()) return false;
|
||||||
|
memset(pStats, 0, sizeof(SteamNetworkingQuickConnectionStatus));
|
||||||
|
|
||||||
|
pStats->m_eState = convert_status(connect_socket->second.status);
|
||||||
|
pStats->m_nPing = 10; //TODO: calculate real numbers?
|
||||||
|
pStats->m_flConnectionQualityLocal = 1.0;
|
||||||
|
pStats->m_flConnectionQualityRemote = 1.0;
|
||||||
|
//TODO: rest
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue