Skip to content

Commit b4530c3

Browse files
committed
add unprivileged events system
1 parent 41c4989 commit b4530c3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/game/shared/gamestate/gamestate.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class CHTTPServerThread : public CThread
9090
"getmode",
9191
"playsound",
9292
"getingame"
93+
},
94+
m_UnprivilegedEvents{
95+
"closedmenu"
9396
}
9497
{
9598
SetName("GameStateHTTPThread");
@@ -156,7 +159,7 @@ class CHTTPServerThread : public CThread
156159
delete userdata;
157160
if ( status_code == 1002 )
158161
{
159-
DebuggerBreak();
162+
DebuggerBreakIfDebugging();
160163
}
161164
Msg("Game state connection closed (%d): %s\n", status_code, reason.c_str());
162165
}
@@ -290,9 +293,10 @@ class CHTTPServerThread : public CThread
290293
{
291294
data["d"] = pEvent->m_strParams;
292295
}
296+
const bool bUnprivileged = m_UnprivilegedMethods.find( pEvent->m_strEvent ) != m_UnprivilegedMethods.end();
293297
for ( auto conn : m_connectedClients )
294298
{
295-
if ( conn )
299+
if ( conn && ( bUnprivileged || m_iPrivilegedClientId == *static_cast<int64_t*>( conn->userdata() ) ) )
296300
{
297301
conn->send_text( data.dump() );
298302
}
@@ -418,6 +422,7 @@ class CHTTPServerThread : public CThread
418422
CThreadMutex m_IncomingEventsMutex;
419423

420424
std::unordered_set<std::string> m_UnprivilegedMethods;
425+
std::unordered_set<std::string> m_UnprivilegedEvents;
421426

422427
int64_t m_iNextClientId = 1;
423428
int64_t m_iPrivilegedClientId = -1;

0 commit comments

Comments
 (0)