WebSocketServer: Add RPC version support to events

This commit is contained in:
tt2468 2021-05-10 22:53:51 -07:00
parent 921bc81a7b
commit 4d6901c075
2 changed files with 5 additions and 2 deletions

View File

@ -186,7 +186,7 @@ std::vector<WebSocketServer::WebSocketSessionState> WebSocketServer::GetWebSocke
} }
// It isn't consistent to directly call the WebSocketServer from the events system, but it would also be dumb to make it unnecessarily complicated. // It isn't consistent to directly call the WebSocketServer from the events system, but it would also be dumb to make it unnecessarily complicated.
void WebSocketServer::BroadcastEvent(uint64_t requiredIntent, std::string eventType, json eventData) void WebSocketServer::BroadcastEvent(uint64_t requiredIntent, std::string eventType, json eventData, uint8_t rpcVersion)
{ {
if (!_server.is_listening()) if (!_server.is_listening())
return; return;
@ -209,6 +209,9 @@ void WebSocketServer::BroadcastEvent(uint64_t requiredIntent, std::string eventT
if (!it.second->IsIdentified()) { if (!it.second->IsIdentified()) {
continue; continue;
} }
if (rpcVersion && it.second->RpcVersion() != rpcVersion) {
continue;
}
if ((it.second->EventSubscriptions() & requiredIntent) != 0) { if ((it.second->EventSubscriptions() & requiredIntent) != 0) {
websocketpp::lib::error_code errorCode; websocketpp::lib::error_code errorCode;
switch (it.second->Encoding()) { switch (it.second->Encoding()) {

View File

@ -79,7 +79,7 @@ class WebSocketServer : QObject
std::string AuthenticationSalt; std::string AuthenticationSalt;
public Q_SLOTS: public Q_SLOTS:
void BroadcastEvent(uint64_t requiredIntent, std::string eventType, json eventData = nullptr); void BroadcastEvent(uint64_t requiredIntent, std::string eventType, json eventData = nullptr, uint8_t rpcVersion = 0);
signals: signals:
void ClientIdentified(const WebSocketSessionState state); void ClientIdentified(const WebSocketSessionState state);