Skip to content

Commit 957a4be

Browse files
app.js added
1 parent 70fcfe0 commit 957a4be

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

csp/js/app.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const host = `127.0.0.1:57772`;
2+
var str=`ws://${host}/chat/WebCourse.ChatWebSocket.cls`;
3+
let ws = new WebSocket(str);
4+
ws.addEventListener(`open`,()=>{
5+
console.log(`we are connected to the chat`);
6+
});
7+
ws.addEventListener(`error`,(err)=>{
8+
console.error(`connection error:`,err);
9+
});
10+
ws.addEventListener(`close`,(e)=>{
11+
console.log(`we are disconnected from the chat.`+e);
12+
});
13+
ws.addEventListener(`message`,({data})=>{
14+
console.log(`Data received from the server`,JSON.stringify(data));
15+
});

0 commit comments

Comments
 (0)