summaryrefslogtreecommitdiff
path: root/usr/share/swiftstory/www/swiftstory-common.js
diff options
context:
space:
mode:
Diffstat (limited to 'usr/share/swiftstory/www/swiftstory-common.js')
-rw-r--r--usr/share/swiftstory/www/swiftstory-common.js8
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');