From 46b34d6515a59cd20cb3342a8d5392127862439f Mon Sep 17 00:00:00 2001 From: ctrlaltca Date: Wed, 6 Feb 2019 09:08:59 +0100 Subject: [PATCH] Add websocket feature (#3562) * add websocket feature * Added 2.7.0_min_version --- common/featureset.cpp | 5 ++++- servatrice/servatrice.ini.example | 2 +- webclient/webclient.js | 15 +++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common/featureset.cpp b/common/featureset.cpp index 90d00b12..43e35150 100644 --- a/common/featureset.cpp +++ b/common/featureset.cpp @@ -23,7 +23,10 @@ void FeatureSet::initalizeFeatureList(QMap &featureList) featureList.insert("mod_log_lookup", false); featureList.insert("idle_client", false); featureList.insert("forgot_password", false); - featureList.insert("2.6.1_min_version", false); // This is temp to force users onto a newer client + featureList.insert("websocket", false); + // These are temp to force users onto a newer client + featureList.insert("2.6.1_min_version", false); + featureList.insert("2.7.0_min_version", false); } void FeatureSet::enableRequiredFeature(QMap &featureList, QString featureName) diff --git a/servatrice/servatrice.ini.example b/servatrice/servatrice.ini.example index 97084e2e..c2aee7c0 100644 --- a/servatrice/servatrice.ini.example +++ b/servatrice/servatrice.ini.example @@ -73,7 +73,7 @@ requireclientid=false ; You can limit the types of clients that connect to the server by requiring different features be available ; on the client. This setting can contain a comma-seperated list of features. if any of the features ; listed in this line are not available on the client the client will be denied access to the server upon -; attempting to log in. Example: "client_id,client_ver" +; attempting to log in. Example: "client_id,client_ver,websocket" requiredfeatures="" ; You can define custom warnings that users are sent when the moderation staff uses the right client warn user diff --git a/webclient/webclient.js b/webclient/webclient.js index 817df455..82170463 100755 --- a/webclient/webclient.js +++ b/webclient/webclient.js @@ -86,7 +86,7 @@ var WebClient = { resetConnectionvars : function () { this.cmdId = 0; - this.pendingCommands = {}; + this.pendingCommands = {}; }, sendCommand : function (cmd, callback) @@ -151,7 +151,7 @@ var WebClient = { WebClient.sendSessionCommand(sc, function() { WebClient.lastPingPending = false; }); - + }, WebClient.options.keepalive); }, @@ -168,6 +168,9 @@ var WebClient = { "feature_set", "room_chat_history", "client_warnings", + "websocket", + "2.6.1_min_version", + "2.7.0_min_version", /* unimplemented features */ "forgot_password", "idle_client", @@ -404,7 +407,7 @@ var WebClient = { this.socket.onclose = function() { WebClient.setStatus(StatusEnum.DISCONNECTED, 'Connection closed'); - } + } this.socket.onerror = function() { WebClient.setStatus(StatusEnum.DISCONNECTED, 'Connection failed'); @@ -412,7 +415,7 @@ var WebClient = { this.socket.onopen = function(){ WebClient.setStatus(StatusEnum.CONNECTED, 'Connected'); - } + } this.socket.onmessage = function(event) { //console.log("Received " + event.data.byteLength + " bytes"); @@ -431,7 +434,7 @@ var WebClient = { { str += String.fromCharCode(uint8msg[i]); } - console.log(str); + console.log(str); } return; } @@ -456,7 +459,7 @@ var WebClient = { WebClient.processRoomEvent(msg.roomEvent); break; } - } + } }, disconnect : function() {