-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_socket_test.html
35 lines (32 loc) · 1.14 KB
/
main_socket_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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Patient</title>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js" integrity="sha384-/KNQL8Nu5gCHLqwqfQjA689Hhoqgi2S84SNUxC3roTe4EhJ9AfLkp8QiQcU8AMzI" crossorigin="anonymous"></script><script type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function() {
// sending a connect request to the server.
var socket = io.connect('http://localhost:5000',{extraHeaders:{'x-access-token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6M30.l0XNQnn4xYlUafFxowInkYLvF3qvdwJ1iPcuf4Y_M90'}});
socket.on ('test connect', function(connectMsg) {
$('#log').append('<br>' + $('<div/>').text('What is the intention of the code: ' + connectMsg.data).html());
});
socket.on('agenda-notify',data=>{
console.log(data)
let confirm = window.confirm("don't forget your pills")
if (confirm){
socket.emit('reminded',{agenda_id:data.body.agenda_id})
}
})
});
</script>
</head>
</head>
<body>
<h1>Example on SocketIO : EduCBA</h1>
<h2>Message Received:</h2>
<div id="log"></div>
</body>
</html>