Compare commits

...

2 Commits

Author SHA1 Message Date
Mr_Goldberg af3b7223bd
Try to use less CI minutes. 2020-10-04 13:15:32 -04:00
Mr_Goldberg 95bebdfb7c
Implement poll groups and missing message fields. 2020-10-04 13:14:49 -04:00
2 changed files with 84 additions and 9 deletions

View File

@ -78,6 +78,7 @@ build_windows:
- DLL_FILES="$(ls ImGui/impls/windows/*.cpp | tr "\n" " ")"; sed "s|ImGui/impls/windows/\*.cpp|$DLL_FILES|g" -i *.bat - DLL_FILES="$(ls ImGui/impls/windows/*.cpp | tr "\n" " ")"; sed "s|ImGui/impls/windows/\*.cpp|$DLL_FILES|g" -i *.bat
- DLL_FILES="$(ls dll/*.proto | tr "\n" " " | sed "s/.proto/.pb.cc/g")"; sed "s|dll/\*.cc|$DLL_FILES|g" -i *.bat - DLL_FILES="$(ls dll/*.proto | tr "\n" " " | sed "s/.proto/.pb.cc/g")"; sed "s|dll/\*.cc|$DLL_FILES|g" -i *.bat
- DLL_FILES="$(ls steamclient_loader/*.cpp | tr "\n" " ")"; sed "s|steamclient_loader/\*.cpp|$DLL_FILES|g" -i *.bat - DLL_FILES="$(ls steamclient_loader/*.cpp | tr "\n" " ")"; sed "s|steamclient_loader/\*.cpp|$DLL_FILES|g" -i *.bat
- sed "s| /MP12 | /MP4 |g" -i *.bat
- export WINEDEBUG=-all - export WINEDEBUG=-all
- wine cmd /c build_win_debug_experimental.bat - wine cmd /c build_win_debug_experimental.bat
- wine cmd /c build_win_release.bat - wine cmd /c build_win_release.bat
@ -96,6 +97,7 @@ build_windows:
build_cmake_linux: build_cmake_linux:
stage: build stage: build
image: ubuntu image: ubuntu
when: manual
before_script: before_script:
- export DEBIAN_FRONTEND=noninteractive - export DEBIAN_FRONTEND=noninteractive
@ -119,6 +121,7 @@ build_cmake_linux:
build_cmake_windows: build_cmake_windows:
stage: build stage: build
image: fedora:29 image: fedora:29
when: manual
before_script: before_script:
- dnf -y install wine wget p7zip sed dos2unix unzip - dnf -y install wine wget p7zip sed dos2unix unzip

View File

@ -44,6 +44,9 @@ struct Connect_Socket {
int64 user_data; int64 user_data;
std::queue<std::string> data; std::queue<std::string> data;
HSteamNetPollGroup poll_group;
unsigned long long packet_receive_counter;
}; };
class Steam_Networking_Sockets : class Steam_Networking_Sockets :
@ -62,6 +65,9 @@ public ISteamNetworkingSockets
std::vector<struct Listen_Socket> listen_sockets; std::vector<struct Listen_Socket> listen_sockets;
std::map<HSteamNetConnection, struct Connect_Socket> connect_sockets; std::map<HSteamNetConnection, struct Connect_Socket> connect_sockets;
std::map<HSteamNetPollGroup, std::list<HSteamNetConnection>> poll_groups;
std::chrono::steady_clock::time_point created;
public: public:
static void steam_callback(void *object, Common_Message *msg) static void steam_callback(void *object, Common_Message *msg)
{ {
@ -90,6 +96,8 @@ Steam_Networking_Sockets(class Settings *settings, class Networking *network, cl
this->callback_results = callback_results; this->callback_results = callback_results;
this->callbacks = callbacks; this->callbacks = callbacks;
this->created = std::chrono::steady_clock::now();
} }
~Steam_Networking_Sockets() ~Steam_Networking_Sockets()
@ -154,6 +162,7 @@ HSteamNetConnection new_connect_socket(SteamNetworkingIdentity remote_identity,
socket.remote_id = remote_id; socket.remote_id = remote_id;
socket.status = status; socket.status = status;
socket.user_data = -1; socket.user_data = -1;
socket.poll_group = k_HSteamNetPollGroup_Invalid;
static HSteamNetConnection socket_id; static HSteamNetConnection socket_id;
++socket_id; ++socket_id;
@ -725,13 +734,15 @@ SteamNetworkingMessage_t *get_steam_message_connection(HSteamNetConnection hConn
pMsg->m_conn = hConn; pMsg->m_conn = hConn;
pMsg->m_identityPeer = connect_socket->second.remote_identity; pMsg->m_identityPeer = connect_socket->second.remote_identity;
pMsg->m_nConnUserData = connect_socket->second.user_data; pMsg->m_nConnUserData = connect_socket->second.user_data;
//TODO pMsg->m_usecTimeReceived = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - created).count();
//pMsg->m_usecTimeReceived = pMsg->m_nMessageNumber = connect_socket->second.packet_receive_counter;
//pMsg->m_nMessageNumber = ++connect_socket->second.packet_receive_counter;
pMsg->m_pfnFreeData = &free_steam_message_data; pMsg->m_pfnFreeData = &free_steam_message_data;
pMsg->m_pfnRelease = &delete_steam_message; pMsg->m_pfnRelease = &delete_steam_message;
pMsg->m_nChannel = 0; pMsg->m_nChannel = 0;
connect_socket->second.data.pop(); connect_socket->second.data.pop();
PRINT_DEBUG("get_steam_message_connection %u %u\n", hConn, size);
return pMsg; return pMsg;
} }
@ -1023,7 +1034,13 @@ ESteamNetworkingAvailability GetAuthenticationStatus( SteamNetAuthenticationStat
HSteamNetPollGroup CreatePollGroup() HSteamNetPollGroup CreatePollGroup()
{ {
PRINT_DEBUG("Steam_Networking_Sockets::CreatePollGroup\n"); PRINT_DEBUG("Steam_Networking_Sockets::CreatePollGroup\n");
return k_HSteamNetPollGroup_Invalid; std::lock_guard<std::recursive_mutex> lock(global_mutex);
static HSteamNetPollGroup poll_group_counter;
++poll_group_counter;
HSteamNetPollGroup poll_group_number = poll_group_counter;
poll_groups[poll_group_number] = std::list<HSteamNetConnection>();
return poll_group_number;
} }
/// Destroy a poll group created with CreatePollGroup(). /// Destroy a poll group created with CreatePollGroup().
@ -1034,7 +1051,21 @@ HSteamNetPollGroup CreatePollGroup()
bool DestroyPollGroup( HSteamNetPollGroup hPollGroup ) bool DestroyPollGroup( HSteamNetPollGroup hPollGroup )
{ {
PRINT_DEBUG("Steam_Networking_Sockets::DestroyPollGroup\n"); PRINT_DEBUG("Steam_Networking_Sockets::DestroyPollGroup\n");
return false; std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto group = poll_groups.find(hPollGroup);
if (group == poll_groups.end()) {
return false;
}
for (auto c : group->second) {
auto connect_socket = connect_sockets.find(c);
if (connect_socket != connect_sockets.end()) {
connect_socket->second.poll_group = k_HSteamNetPollGroup_Invalid;
}
}
poll_groups.erase(group);
return true;
} }
/// Assign a connection to a poll group. Note that a connection may only belong to a /// Assign a connection to a poll group. Note that a connection may only belong to a
@ -1053,8 +1084,33 @@ bool DestroyPollGroup( HSteamNetPollGroup hPollGroup )
/// is invalid (and not k_HSteamNetPollGroup_Invalid). /// is invalid (and not k_HSteamNetPollGroup_Invalid).
bool SetConnectionPollGroup( HSteamNetConnection hConn, HSteamNetPollGroup hPollGroup ) bool SetConnectionPollGroup( HSteamNetConnection hConn, HSteamNetPollGroup hPollGroup )
{ {
PRINT_DEBUG("Steam_Networking_Sockets::SetConnectionPollGroup\n"); PRINT_DEBUG("Steam_Networking_Sockets::SetConnectionPollGroup %u %u\n", hConn, hPollGroup);
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;
}
auto group = poll_groups.find(hPollGroup);
if (group == poll_groups.end() && hPollGroup != k_HSteamNetPollGroup_Invalid) {
return false;
}
HSteamNetPollGroup old_poll_group = connect_socket->second.poll_group;
if (old_poll_group != k_HSteamNetPollGroup_Invalid) {
auto group = poll_groups.find(hPollGroup);
if (group != poll_groups.end()) {
group->second.remove(hConn);
}
}
connect_socket->second.poll_group = hPollGroup;
if (hPollGroup == k_HSteamNetPollGroup_Invalid) {
return true;
}
group->second.push_back(hConn);
return true;
} }
/// Same as ReceiveMessagesOnConnection, but will return the next messages available /// Same as ReceiveMessagesOnConnection, but will return the next messages available
@ -1074,8 +1130,24 @@ bool SetConnectionPollGroup( HSteamNetConnection hConn, HSteamNetPollGroup hPoll
/// other connections.) /// other connections.)
int ReceiveMessagesOnPollGroup( HSteamNetPollGroup hPollGroup, SteamNetworkingMessage_t **ppOutMessages, int nMaxMessages ) int ReceiveMessagesOnPollGroup( HSteamNetPollGroup hPollGroup, SteamNetworkingMessage_t **ppOutMessages, int nMaxMessages )
{ {
PRINT_DEBUG("Steam_Networking_Sockets::ReceiveMessagesOnPollGroup\n"); PRINT_DEBUG("Steam_Networking_Sockets::ReceiveMessagesOnPollGroup %u %i\n", hPollGroup, nMaxMessages);
return -1; std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto group = poll_groups.find(hPollGroup);
if (group == poll_groups.end()) {
return 0;
}
SteamNetworkingMessage_t *msg = NULL;
int messages = 0;
for (auto c : group->second) {
while ((msg = get_steam_message_connection(c)) && messages < nMaxMessages) {
ppOutMessages[messages] = msg;
++messages;
}
}
return messages;
} }