-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
30 lines (25 loc) · 806 Bytes
/
Copy pathmain.js
File metadata and controls
30 lines (25 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// html page will use the functions below to send data to the webserver
$(function () {
var socket = io();
const setUsername = () => {
// fires the add user event
// will define username later
socket.emit('add user', username);
}
const addIntroMessage = (data) => {
var message = '';
// check numUsers for number of users. numUsers in defined in index.js
if (data.numUsers === 1) {
message += "There's only one participant right now."
}
else {
message += "There are " + data.numUsers + " participants";
}
}
const sendMessage = () => {
if (message && connected) {
// fires the new message event
socket.emit('new message', message);
}
}
})