/
scla.mjs
70 lines (64 loc) · 2.29 KB
/
scla.mjs
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
import WComorWebsocketClient from './src/WComorWebsocketClient.mjs'
//import WComorWebsocketClient from './dist/w-comor-websocket-client.umd.js'
let opt = {
url: 'ws://localhost:8080',
token: '*',
open: function() {
console.log('client nodejs[port:8080]: open')
},
close: function() {
console.log('client nodejs[port:8080]: close')
},
error: function(err) {
console.log('client nodejs[port:8080]: error:', err)
},
reconn: function() {
console.log('client nodejs[port:8080]: reconn')
},
}
new WComorWebsocketClient(opt)
.then(function(wo) {
console.log('client nodejs[port:8080]: funcs: ', wo)
function core(ps) {
wo.group.plus(ps)
.then(function(r) {
console.log('client nodejs[port:8080]: plus(' + JSON.stringify(ps) + ')=' + r)
})
.catch(function(err) {
console.log('client nodejs[port:8080]: plus: catch: ', err)
})
wo.group.div(ps)
.then(function(r) {
console.log('client nodejs[port:8080]: div(' + JSON.stringify(ps) + ')=' + r)
})
.catch(function(err) {
console.log('client nodejs[port:8080]: div: catch: ', err)
})
wo.add(ps)
.then(function(r) {
console.log('client nodejs[port:8080]: add(' + JSON.stringify(ps) + ')=' + r)
})
.catch(function(err) {
console.log('client nodejs[port:8080]: add: catch: ', err)
})
wo.minu(ps)
.then(function(r) {
console.log('client nodejs[port:8080]: minu(' + JSON.stringify(ps) + ')=' + r)
})
.catch(function(err) {
console.log('client nodejs[port:8080]: minu: catch: ', err)
})
}
let i = 100
setInterval(function() {
i += 1
core({
p1: i,
p2: 10,
})
}, 1000)
})
.catch(function(err) {
console.log('client nodejs[port:8080]: catch: ', err)
})
//node --experimental-modules --es-module-specifier-resolution=node scla.mjs