Mercurial > hg > rlgwebd
comparison rlgterm.js @ 201:f3843245a35e
Initial support for TLS.
RLGWebD now serves via encrypted connections on port 8081.
The client-side script now uses secure WebSockets if the page is being
accessed via HTTPS.
author | John "Elwin" Edwards |
---|---|
date | Sun, 01 Jan 2017 20:18:01 -0500 |
parents | 9758ca68e7f1 |
children |
comparison
equal
deleted
inserted
replaced
200:a7cc38a0168d | 201:f3843245a35e |
---|---|
394 /* When starting the socket, the choices list might not be initialized. */ | 394 /* When starting the socket, the choices list might not be initialized. */ |
395 getchoices(); | 395 getchoices(); |
396 } | 396 } |
397 if (statsock) | 397 if (statsock) |
398 return; | 398 return; |
399 statsock = new WebSocket("ws://" + window.location.host + "/status"); | 399 var wsproto = "ws://"; |
400 if (window.location.protocol == "https:") | |
401 wsproto = "wss://"; | |
402 statsock = new WebSocket(wsproto + window.location.host + "/status"); | |
400 statsock.onmessage = function (ev) { | 403 statsock.onmessage = function (ev) { |
401 var msg; | 404 var msg; |
402 try { | 405 try { |
403 msg = JSON.parse(ev.data); | 406 msg = JSON.parse(ev.data); |
404 } catch (e) { | 407 } catch (e) { |
616 if (!("lcred" in sessionStorage) || session.connect) | 619 if (!("lcred" in sessionStorage) || session.connect) |
617 return; | 620 return; |
618 if (!window.WebSocket) { | 621 if (!window.WebSocket) { |
619 return; | 622 return; |
620 } | 623 } |
621 var sockurl = "ws://" + window.location.host + "/play/" + game.uname; | 624 var wsproto = "ws://"; |
625 if (window.location.protocol == "https:") | |
626 wsproto = "wss://"; | |
627 var sockurl = wsproto + window.location.host + "/play/" + game.uname; | |
622 sockurl += "?key=" + sessionStorage.getItem("lcred") + "&w=80&h=24"; | 628 sockurl += "?key=" + sessionStorage.getItem("lcred") + "&w=80&h=24"; |
623 ws = new WebSocket(sockurl); | 629 ws = new WebSocket(sockurl); |
624 ws.onopen = function (event) { | 630 ws.onopen = function (event) { |
625 session.connect = true; | 631 session.connect = true; |
626 session.playing = true; | 632 session.playing = true; |
651 } | 657 } |
652 | 658 |
653 function startwatching(tag) { | 659 function startwatching(tag) { |
654 if (session.connect) | 660 if (session.connect) |
655 return; | 661 return; |
656 var sockurl = "ws://" + window.location.host + "/watch/" + tag; | 662 var wsproto = "ws://"; |
663 if (window.location.protocol == "https:") | |
664 wsproto = "wss://"; | |
665 var sockurl = wsproto + window.location.host + "/watch/" + tag; | |
657 var ws = new WebSocket(sockurl); | 666 var ws = new WebSocket(sockurl); |
658 ws.onopen = function (event) { | 667 ws.onopen = function (event) { |
659 session.connect = true; | 668 session.connect = true; |
660 session.sock = ws; | 669 session.sock = ws; |
661 setmode("watch"); | 670 setmode("watch"); |