From 72bd3e4c9820eb9d94f7f59c5cff8ce9f6ff774d Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 26 Apr 2016 21:57:11 -0700 Subject: [PATCH] Add localStorage flag for connecting to alt server list --- src/backend/backendmodule.js | 3 ++- www/js/callbacks.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/backend/backendmodule.js b/src/backend/backendmodule.js index 2fcb7ee7..c9cfd8bc 100644 --- a/src/backend/backendmodule.js +++ b/src/backend/backendmodule.js @@ -37,7 +37,8 @@ class BackendModule { const redisClientProvider = this.getRedisClientProvider(); this.redisAdapter = redisAdapter({ pubClient: redisClientProvider.get(), - subClient: redisClientProvider.get() + // return_buffers is needed for msgpack-js to function correctly + subClient: redisClientProvider.get({ return_buffers: true }) }); this.sioEmitter = require('socket.io').instance; this.sioEmitter.adapter(this.redisAdapter); diff --git a/www/js/callbacks.js b/www/js/callbacks.js index fd6b47ec..67b2d6dc 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -1119,8 +1119,17 @@ setupCallbacks = function() { return; } + var servers; + if (socketConfig.alt && socketConfig.alt.length > 0 && + localStorage.useAltServer) { + servers = socketConfig.alt; + console.log("Using alt servers: " + JSON.stringify(servers)); + } else { + servers = socketConfig.servers; + } + var chosenServer = null; - socketConfig.servers.forEach(function (server) { + servers.forEach(function (server) { if (chosenServer === null) { chosenServer = server; } else if (server.secure && !chosenServer.secure) { @@ -1130,6 +1139,8 @@ setupCallbacks = function() { } }); + console.log("Connecting to " + JSON.stringify(chosenServer)); + if (chosenServer === null) { makeAlert("Error", "Socket.io configuration was unable to find a suitable server",