-
Notifications
You must be signed in to change notification settings - Fork 0
/
ws_test.html
62 lines (45 loc) · 1.79 KB
/
ws_test.html
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>웹 소켓 테스트 할꼬잉</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.5.1/sockjs.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>
<!-- jquery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"
integrity="sha512-NFUcDlm4V+a2sjPX7gREIXgCSFja9cHtKPOL1zj6QhnE0vcY695MODehqkaGYTLyL2wxe/wtr4Z49SvqXq12UQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>
</body>
<script type="text/javascript">
$(document).ready(function () {
connectServer();
});
var stompClient = null;
function connectServer() {
var url = 'https://online-judge-api.yoonleeverse.com/ws';
var socket = new SockJS(url);
stompClient = Stomp.over(socket);
stompClient.connect({ 'Authorization': 'Bearer ' },
function (frame) {
console.log('Connected: ' + frame);
stompClient.subscribe("/user/queue/notification", function(message) {
const res = JSON.parse(message.body);
console.log(res);
});
stompClient.subscribe("/user/queue/problem/run", function(message) {
const res = JSON.parse(message.body);
console.log(res);
});
},
function (message) {
alert("disconnect:" + message);
}
);
}
</script>
</html>