Improved web socket port detection (added support for window.location.port).

This commit is contained in:
Martin Edenhofer 2016-09-06 15:56:36 +02:00
parent be67419379
commit 022cceaf60

View file

@ -199,10 +199,13 @@ class _webSocketSingleton extends App.Controller
protocol = 'wss://'
if @backend is 'websocket'
@ws = new window.WebSocket( protocol + window.location.hostname + '/ws' )
port = ''
if window.location.port && window.location.port != ''
port = ":#{window.location.port}"
@ws = new window.WebSocket("#{protocol}#{window.location.hostname}#{port}/ws")
else if @backend is 'websocketPort'
@backend_port = App.Config.get('websocket_port') || '6042'
@ws = new window.WebSocket( protocol + window.location.hostname + ':' + @backend_port + '/' )
@ws = new window.WebSocket("#{protocol}#{window.location.hostname}:#{@backend_port}/")
else
@_ajaxInit()