Skip to content
Permalink
Browse files

Add option for SSL in client, automatically set ssl on port 1114.

  • Loading branch information...
Shinmera committed Nov 23, 2017
1 parent 788f632 commit 0f851c98ec463a6e785e74bed87eaffd0c5240d6
Showing with 5 additions and 2 deletions.
  1. +2 −1 client.js
  2. +1 −0 index.js
  3. +2 −1 lichat.js
@@ -20,6 +20,7 @@ var LichatClient = function(options){
self.pingDelay = 15000;
self.emotes = {};
self.channels = [];
self.ssl = false;

if(window.localStorage){
self.emotes = JSON.parse(window.localStorage.getItem("emotes")) || {};
@@ -36,7 +37,7 @@ var LichatClient = function(options){

self.openConnection = ()=>{
status = "STARTING";
var socket = new WebSocket("ws://"+self.hostname+":"+self.port, "lichat");
var socket = new WebSocket((self.ssl?"wss://":"ws://")+self.hostname+":"+self.port, "lichat");
socket.onopen = ()=>{
self.s("CONNECT", {password: self.password || null,
version: LichatVersion,
@@ -78,6 +78,7 @@ login.addEventListener("submit", (ev)=>{
client.password = login.querySelector("input[name=password]").value;
client.hostname = login.querySelector("input[name=hostname]").value;
client.port = parseInt(login.querySelector("input[name=port]").value);
client.ssl = (client.port === 1114);
save("username", client.username);
save("password", client.password);
save("hostname", client.hostname);
@@ -936,6 +936,7 @@ var LichatClient = function(options){
self.pingDelay = 15000;
self.emotes = {};
self.channels = [];
self.ssl = false;

if(window.localStorage){
self.emotes = JSON.parse(window.localStorage.getItem("emotes")) || {};
@@ -952,7 +953,7 @@ var LichatClient = function(options){

self.openConnection = ()=>{
status = "STARTING";
var socket = new WebSocket("ws://"+self.hostname+":"+self.port, "lichat");
var socket = new WebSocket((self.ssl?"wss://":"ws://")+self.hostname+":"+self.port, "lichat");
socket.onopen = ()=>{
self.s("CONNECT", {password: self.password || null,
version: LichatVersion,

0 comments on commit 0f851c9

Please sign in to comment.
You can’t perform that action at this time.