Initial commit
This commit is contained in:
17
static/index.html
Normal file
17
static/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Document</title>
|
||||
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script defer src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<input type="text" id="text" />
|
||||
<button id="send">Send</button>
|
||||
<br />
|
||||
|
||||
<div id="messages"></div>
|
||||
</body>
|
||||
</html>
|
||||
14
static/index.js
Normal file
14
static/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const input = document.getElementById("text");
|
||||
const send = document.getElementById("send");
|
||||
const messages = document.getElementById("messages");
|
||||
|
||||
const socket = io();
|
||||
|
||||
socket.on("text", (data) => {
|
||||
console.log(data);
|
||||
messages.innerHTML += `${data}<br>`;
|
||||
});
|
||||
|
||||
send.addEventListener("click", () => {
|
||||
socket.emit("text", input.value);
|
||||
});
|
||||
Reference in New Issue
Block a user