-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.js
More file actions
34 lines (29 loc) · 767 Bytes
/
Copy pathclient.js
File metadata and controls
34 lines (29 loc) · 767 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
31
32
33
34
let socket=io();
$('#loginBox').show();
$(`#chatBox`).hide();
$('#btnStart').click(()=>{
socket.emit('login',{
username: $('#inpUserName').val(),
password: $('#inpUserPass').val()
})
})
socket.on('logged_in',()=>{
$('#loginBox').hide();
$(`#chatBox`).show();
})
$('#btnSendMsg').click(()=>{
socket.emit('msg_send',{
to: $('#inpToUser').val() ,
msg:$('#inpNewMsg').val()
})
})
socket.on('msg_rcvd',(data)=>{
// let x=document.createElement('li');
// x.innerText=data.msg ;
// $('#ulMsgs').append(x);
$('#ulMsgs').append($(`<li>`).text(
` [${data.from}]: ${data.msg} `))
})
socket.on('login_failed',()=>{
window.alert("Wrong UserName or Password")
})