Merge pull request #1924 from loafoe/master

[#1923] Make Websocket ports configurable
Этот коммит содержится в:
Christopher Speller
2016-01-21 10:01:15 -05:00
родитель 868eece987 ff8df5bf7d
Коммит c7faefbedc
5 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@@ -49,7 +49,7 @@ class SocketStoreClass extends EventEmitter {
protocol = 'wss://';
}
var connUrl = protocol + location.host + '/api/v1/websocket?' + Utils.getSessionIndex();
var connUrl = protocol + location.host + ((/:\d+/).test(location.host) ? '' : Utils.getWebsocketPort(protocol)) + '/api/v1/websocket?' + Utils.getSessionIndex();
if (this.failCount === 0) {
console.log('websocket connecting to ' + connUrl); //eslint-disable-line no-console

Просмотреть файл

@@ -1101,6 +1101,17 @@ export function getFileName(path) {
return split[split.length - 1];
}
// Gets the websocket port to use. Configurable on the server.
export function getWebsocketPort(protocol) {
if ((/^wss:/).test(protocol)) { // wss://
return ':' + global.window.mm_config.WebsocketSecurePort;
}
if ((/^ws:/).test(protocol)) {
return ':' + global.window.mm_config.WebsocketPort;
}
return '';
}
export function getSessionIndex() {
if (global.window.mm_session_token_index >= 0) {
return 'session_token_index=' + global.window.mm_session_token_index;