-
Notifications
You must be signed in to change notification settings - Fork 0
/
web-c1p0-pd.html
92 lines (70 loc) · 2.66 KB
/
web-c1p0-pd.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
<!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: 0, //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')
//subTopic
wo.subTopic(missionTopic)
function addMission(n) {
//input
let input = '#' + n
//option
let option = {}
//pushQueue
wo.pushQueue(missionTopic, input, option)
}
//mission
let n = 0
let t = setInterval(function() {
n += 1
addMission(n)
if (n === 10) {
clearInterval(t)
}
}, 20)
})
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) {
//console.log('client web: queueChange', topic, id, input, output, state)
})
</script>
</head>
<body>
</body>
</html>