|
@@ -16,7 +16,16 @@ window.onload = function() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const socket = new WebSocket("ws://localhost:8000/socket");
|
|
|
+ var loc = window.location, new_uri;
|
|
|
+ if (loc.protocol === "https:") {
|
|
|
+ new_uri = "wss:";
|
|
|
+ } else {
|
|
|
+ new_uri = "ws:";
|
|
|
+ }
|
|
|
+ new_uri += "//" + loc.host;
|
|
|
+ new_uri += loc.pathname + "socket";
|
|
|
+
|
|
|
+ const socket = new WebSocket(new_uri);
|
|
|
socket.addEventListener("open", function (event) {
|
|
|
console.log("Connected to server!");
|
|
|
socket.send(JSON.stringify(config));
|
|
@@ -31,7 +40,6 @@ window.onload = function() {
|
|
|
|
|
|
|
|
|
$('#chatbox').on('keypress', function (e) {
|
|
|
- console.log('!!!');
|
|
|
if (e.which === 13) {
|
|
|
$(this).attr("disabled", "disabled");
|
|
|
socket.send(JSON.stringify({"content": $('#chatbox').val()}))
|