mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
WebSocketSession: Add mutex for operations which change session parameters
This commit is contained in:
parent
4be9b995fb
commit
ffaac93ba6
@ -49,6 +49,7 @@ WebSocketProtocol::ProcessResult WebSocketProtocol::ProcessMessage(SessionPtr se
|
||||
} else if (messageType == "RequestBatch") {
|
||||
;
|
||||
} else if (messageType == "Identify") {
|
||||
std::unique_lock<std::mutex> sessionLock(session->OperationMutex);
|
||||
if (session->IsIdentified()) {
|
||||
if (!session->IgnoreInvalidMessages()) {
|
||||
ret.closeCode = WebSocketServer::WebSocketCloseCode::AlreadyIdentified;
|
||||
@ -87,7 +88,7 @@ WebSocketProtocol::ProcessResult WebSocketProtocol::ProcessMessage(SessionPtr se
|
||||
ret.result["negotiatedRpcVersion"] = session->RpcVersion();
|
||||
return ret;
|
||||
} else if (messageType == "Reidentify") {
|
||||
;
|
||||
std::unique_lock<std::mutex> sessionLock(session->OperationMutex);
|
||||
} else {
|
||||
if (!session->IgnoreInvalidMessages()) {
|
||||
ret.closeCode = WebSocketServer::WebSocketCloseCode::UnknownMessageType;
|
||||
|
@ -253,6 +253,7 @@ void WebSocketServer::onOpen(websocketpp::connection_hdl hdl)
|
||||
// Build new session
|
||||
std::unique_lock<std::mutex> lock(_sessionMutex);
|
||||
SessionPtr session = _sessions[hdl] = std::make_shared<WebSocketSession>();
|
||||
std::unique_lock<std::mutex> sessionLock(session->OperationMutex);
|
||||
lock.unlock();
|
||||
|
||||
// Configure session details
|
||||
@ -284,6 +285,8 @@ void WebSocketServer::onOpen(websocketpp::connection_hdl hdl)
|
||||
helloMessage["authentication"]["salt"] = AuthenticationSalt;
|
||||
}
|
||||
|
||||
sessionLock.unlock();
|
||||
|
||||
// Send object to client
|
||||
websocketpp::lib::error_code errorCode;
|
||||
auto sessionEncoding = session->Encoding();
|
||||
|
@ -42,6 +42,8 @@ class WebSocketSession
|
||||
uint64_t EventSubscriptions();
|
||||
void SetEventSubscriptions(uint64_t subscriptions);
|
||||
|
||||
std::mutex OperationMutex;
|
||||
|
||||
private:
|
||||
std::mutex _remoteAddressMutex;
|
||||
std::string _remoteAddress;
|
||||
|
Loading…
Reference in New Issue
Block a user