mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-12-24 19:58:37 +01:00
Implement some networking sockets functions.
This commit is contained in:
parent
6d5cb3181f
commit
a0e558ed4c
2 changed files with 38 additions and 2 deletions
|
@ -755,6 +755,7 @@ EResult SendMessageToConnection( HSteamNetConnection hConn, const void *pData, u
|
|||
bool reliable = false;
|
||||
if (nSendFlags & k_nSteamNetworkingSend_Reliable) reliable = true;
|
||||
|
||||
if (pOutMessageNumber) *pOutMessageNumber = 1; //TODO
|
||||
if (network->sendTo(&msg, reliable)) return k_EResultOK;
|
||||
return k_EResultFail;
|
||||
}
|
||||
|
@ -800,6 +801,20 @@ EResult SendMessageToConnection( HSteamNetConnection hConn, const void *pData, u
|
|||
void SendMessages( int nMessages, SteamNetworkingMessage_t *const *pMessages, int64 *pOutMessageNumberOrResult )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Sockets::SendMessages\n");
|
||||
for (int i = 0; i < nMessages; ++i) {
|
||||
int64 out_number = 0;
|
||||
int result = SendMessageToConnection(pMessages[i]->m_conn, pMessages[i]->m_pData, pMessages[i]->m_cbSize, pMessages[i]->m_nFlags, &out_number);
|
||||
if (pOutMessageNumberOrResult) {
|
||||
if (result == k_EResultOK) {
|
||||
pOutMessageNumberOrResult[i] = out_number;
|
||||
} else {
|
||||
pOutMessageNumberOrResult[i] = -result;
|
||||
}
|
||||
}
|
||||
|
||||
pMessages[i]->m_pfnFreeData(pMessages[i]);
|
||||
pMessages[i]->Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,18 @@ Steam_Networking_Utils(class Settings *settings, class Networking *network, clas
|
|||
this->run_every_runcb->remove(&Steam_Networking_Utils::steam_run_every_runcb, this);
|
||||
}
|
||||
|
||||
static void free_steam_message_data(SteamNetworkingMessage_t *pMsg)
|
||||
{
|
||||
free(pMsg->m_pData);
|
||||
pMsg->m_pData = NULL;
|
||||
}
|
||||
|
||||
static void delete_steam_message(SteamNetworkingMessage_t *pMsg)
|
||||
{
|
||||
if (pMsg->m_pfnFreeData) pMsg->m_pfnFreeData(pMsg);
|
||||
delete pMsg;
|
||||
}
|
||||
|
||||
/// Allocate and initialize a message object. Usually the reason
|
||||
/// you call this is to pass it to ISteamNetworkingSockets::SendMessages.
|
||||
/// The returned object will have all of the relevant fields cleared to zero.
|
||||
|
@ -90,8 +102,17 @@ Steam_Networking_Utils(class Settings *settings, class Networking *network, clas
|
|||
SteamNetworkingMessage_t *AllocateMessage( int cbAllocateBuffer )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::AllocateMessage\n");
|
||||
//TODO
|
||||
return NULL;
|
||||
SteamNetworkingMessage_t *pMsg = new SteamNetworkingMessage_t();
|
||||
pMsg->m_pfnFreeData = &free_steam_message_data;
|
||||
pMsg->m_pfnRelease = &delete_steam_message;
|
||||
if (cbAllocateBuffer < 0)
|
||||
cbAllocateBuffer = 0;
|
||||
|
||||
if (cbAllocateBuffer)
|
||||
pMsg->m_pData = malloc(cbAllocateBuffer);
|
||||
|
||||
pMsg->m_cbSize = cbAllocateBuffer;
|
||||
return pMsg;
|
||||
}
|
||||
|
||||
bool InitializeRelayAccess()
|
||||
|
|
Loading…
Reference in a new issue