-
Notifications
You must be signed in to change notification settings - Fork 0
/
web-c1p0-cm.html
106 lines (78 loc) · 3.16 KB
/
web-c1p0-cm.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-tw">
<head>
<meta http-equiv="content-type" content="text/html charset=UTF-8" />
<title>w-runqws</title>
<script nomodule src="https://cdn.jsdelivr.net/npm/@babel/polyfill/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/wsemi/dist/wsemi.umd.js"></script>
<script src="dist/w-runqws-client.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/w-consolelog/dist/w-consolelog.umd.js"></script>
<script>
console.log = window['w-consolelog']
</script>
<script>
let opt = {
url: 'ws://localhost:8080',
token: '*',
takeNumLimit: 1, //0 for non-blocking, 1~n for blocking and need to call cb() in queueChange
}
let missionTopic = 'parser|texts'
//new
let WRunqwsClient = window['w-runqws-client']
let wo = new WRunqwsClient(opt)
wo.on('open', function() {
console.log('client web: open')
// //delQueueByTopic
// wo.delQueueByTopic(missionTopic)
// .then(function(msg) {
// console.log('delQueueByTopic', msg)
// })
//subTopic
wo.subTopic(missionTopic)
})
wo.on('openOnce', function() {
console.log('client web: openOnce')
})
wo.on('close', function() {
console.log('client web: close')
})
wo.on('error', function(err) {
console.log('client web: error', err)
})
wo.on('reconn', function() {
console.log('client web: reconn')
})
wo.on('broadcast', function(data) {
console.log('client web: broadcast', data)
})
wo.on('deliver', function(data) {
//console.log('client web: deliver', data)
})
wo.on('queueChange', function(topic, id, input, output, state, cb) {
//console.log('client web: queueChange', topic, id, input, output, state, cb)
//ready queue
if (topic === missionTopic && state === 'ready') {
console.log('queueChange', input, output, state)
setTimeout(function() {
//output
output = 'done(' + input.replace('#', '') + ')'
//state
state = 'finish'
//modifyQueue
wo.modifyQueue(topic, id, input, output, state)
//cb
console.log('queueChange done', input, output, state)
cb()
}, 1000)
}
else {
//cb
//console.log('queueChange skip', input, output, state)
cb()
}
})
</script>
</head>
<body>
</body>
</html>