diff --git a/src/server/WebSocket.cpp b/src/server/WebSocket.cpp index b44e47a..6748638 100644 --- a/src/server/WebSocket.cpp +++ b/src/server/WebSocket.cpp @@ -13,6 +13,7 @@ WebSocket::WebSocket(QWebSocket *sock, QString ID, AuthorizationManager *auth){ SockID = ID; + isBridge = false; SockAuthToken.clear(); //nothing set initially SOCKET = sock; TSOCKET = 0; @@ -126,6 +127,8 @@ void WebSocket::EvaluateREST(QString msg){ if(IN.name.startsWith("auth") || (IN.namesp.toLower()=="rpc" && IN.name.toLower()=="identify") ){ //Keep auth/pre-auth system requests in order EvaluateRequest(IN); + }else if(isBridge && (IN.name=="response" || (IN.namesp=="events" && IN.name=="bridge") ) ){ + EvaluateResponse(IN); }else{ QtConcurrent::run(this, &WebSocket::EvaluateRequest, IN); } @@ -296,6 +299,20 @@ if(out.in_struct.namesp.toLower() == "rpc"){ } } +void WebSocket::EvaluateResponse(const RestInputStruct& IN){ + if(IN.namesp=="events" && IN.name=="bridge"){ + QStringList bids = JsonArrayToStringList(IN.args.toObject().value("available_connections").toArray()); + QStringList keys = BRIDGE.keys(); + for(int i=0; iclearAuth(BRIDGE[keys[i]].auth_tok); BRIDGE.remove(keys[i]); } //no longer available + } + //Now add any new bridge ID's to the hash + for(int i=0; i ForwardEvents; + //Data handling for bridged connections (1 connection for multiple clients) + QHash BRIDGE; //ID/data + bool isBridge; + // Where we store incoming Tcp data QString incomingbuffer; void ParseIncoming(); - //Main connection comminucations procedure + //Main connection communications procedure void EvaluateREST(QString); //STAGE 1 response: Text -> Rest/JSON struct void EvaluateRequest(const RestInputStruct&); //STAGE 2 response: Parse Rest/JSON (does auth/events) + //Response handling + void EvaluateResponse(const RestInputStruct&); //Simplification functions QString JsonValueToString(QJsonValue);