diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-03-09 13:38:23 +0100 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-03-09 13:38:23 +0100 |
commit | a0ec553fb703f36e935ff616d8ace663664e21c8 (patch) | |
tree | 4033e0948a89dda4c09b4b996881159fcc1ff7c2 /usr/share/swiftstory/www/swiftstory-common.js | |
parent | 540e4b9bd685af8272114a0d0722b69eaafa7e82 (diff) |
connect to the websocket on the same host using wss or ws
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'usr/share/swiftstory/www/swiftstory-common.js')
-rw-r--r-- | usr/share/swiftstory/www/swiftstory-common.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr/share/swiftstory/www/swiftstory-common.js b/usr/share/swiftstory/www/swiftstory-common.js index 174b473..5d19555 100644 --- a/usr/share/swiftstory/www/swiftstory-common.js +++ b/usr/share/swiftstory/www/swiftstory-common.js @@ -214,7 +214,13 @@ var SwiftStory = function() { /* }}} */ this.run = function() { - ws = new WebSocket('ws://' + document.location.hostname + ':1236'); + /* Use websockets over TLS only when the page is served over TLS. */ + var scheme = (document.location.protocol === 'https:') ? 'wss' : 'ws'; + + /* NOTE: We need to access the exact url (no redirection allowed). */ + var uri = scheme + '://' + document.location.host + '/ws/'; + + ws = new WebSocket(uri); ws.onopen = function() { console.log('connection established'); |