hrtjji[erj[iogrst
This commit is contained in:
parent
3c0f77b7eb
commit
b841e066b9
1 changed files with 8 additions and 2 deletions
10
client.js
10
client.js
|
@ -17,6 +17,11 @@ function log(...args) {
|
|||
|
||||
let wsurl = new URL(document.location.toString());
|
||||
wsurl.port = 3000;
|
||||
if (document.location.protocol == "http") {
|
||||
wsurl.protocol = "ws";
|
||||
} else {
|
||||
wsurl.protocol = "wss";
|
||||
}
|
||||
let conn = new WebSocket(wsurl);
|
||||
|
||||
conn.onmessage = (ev) => {
|
||||
|
@ -27,9 +32,10 @@ conn.onmessage = (ev) => {
|
|||
newMsg.appendChild(messageContents);
|
||||
document.getElementById("chat-body").appendChild(newMsg);
|
||||
};
|
||||
|
||||
/**
|
||||
* @type {HTMLInputElement}
|
||||
*/
|
||||
* @type {HTMLInputElement}
|
||||
*/
|
||||
let input = document.getElementById("chat-input");
|
||||
input.onchange = (_) => {
|
||||
conn.send(input.value.toString());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue