-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.js
46 lines (33 loc) · 816 Bytes
/
events.js
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
const deepstream = require('deepstream.io-client-js')
const clientA = deepstream('localhost:6020').login()
const clientB = deepstream('localhost:6020').login()
clientB.event.emit('my_event')
setTimeout(function () {
clientA.event.subscribe('my_event', () => {
console.log('clientA subscribed')
})
}, 30)
setTimeout(() => {
clientB.event.subscribe('my_event', () => {
console.log('clientB subscribed')
})
}, 50)
setTimeout(() => {
clientB.event.emit('my_event')
}, 80)
setTimeout(() => {
clientA.event.unsubscribe('my_event')
}, 100)
setTimeout(() => {
clientB.event.emit('my_event')
}, 120)
setTimeout(() => {
clientB.event.unsubscribe('my_event')
}, 140)
setTimeout(() => {
clientB.event.emit('my_event')
}, 160)
setTimeout(() => {
clientA.close()
clientB.close()
}, 200)