-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
74 lines (68 loc) · 2.08 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
<html lang="en">
<head>
<meta charset="utf-8">
<title>EventServer</title>
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
<script src="https://cdn.jsdelivr.net/sockjs/1/sockjs.min.js"></script>
<script src="https://rawgit.com/vert-x3/vertx-bus-bower/master/vertx-eventbus.js"></script>
</head>
<body>
<div>
<input type="text" id="textInput"/>
<button onclick="submitMessage()">Send Text</button>
</div>
<div>
<input type="text" id="authToken"/>
<button onclick="openEB()">Open Event Bus</button>
</div>
<script>
/*
var sock = new SockJS('/events');
sock.onopen = function() {
console.log('open');
};
sock.onmessage = function(e) {
console.log('sock-message', e.data);
};
sock.onclose = function() {
console.log('close');
};
*/
var eb;
window.openEB = function() {
eb = new EventBus('/eventbus');
eb.onopen = function() {
var headers = {
"Auth-Token" : document.getElementById("authToken").value
};
eb.registerHandler('chat.public.out', headers, function(error, msg) {
console.log('chat.public.out', JSON.stringify(msg));
});
setTimeout(function(){
eb.registerHandler('chat.location.out', headers, function(error, msg) {
console.log('chat.location.out', JSON.stringify(msg));
});
eb.registerHandler('chat.party.out', headers, function(error, msg) {
console.log('chat.location.out', JSON.stringify(msg));
});
eb.registerHandler('chat.group.out', headers, function(error, msg) {
console.log('chat.location.out', JSON.stringify(msg));
});
eb.registerHandler('chat.private.out', headers, function(error, msg) {
console.log('chat.location.out', JSON.stringify(msg));
});
}, 1500);
}
};
window.submitMessage = function() {
var text = document.getElementById("textInput").value;
eb.send('chat.public.in', {'contents': text});
eb.send('chat.location.in', {'contents': text});
eb.send('chat.group.in', {'contents': text});
eb.send('chat.party.in', {'contents': text});
}
</script>
</body>
</html>