Add localStorage flag for connecting to alt server list

This commit is contained in:
calzoneman 2016-04-26 21:57:11 -07:00
parent a33f3d8bb0
commit 72bd3e4c98
2 changed files with 14 additions and 2 deletions

View File

@ -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);

View File

@ -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",