Skip to content

Commit 6b1ecfb

Browse files
author
Vitaliy Stoliarov
committed
uodate 'sequencing' example
1 parent fef538f commit 6b1ecfb

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

examples/ws2/sequencing.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
const _isArray = require('lodash/isArray')
44
const _isFinite = require('lodash/isFinite')
5-
const runExample = require('../util/run_example')
5+
const { args: { apiKey, apiSecret }, debug } = require('../util/setup')
6+
const WSv2 = require('../../lib/transports/ws2')
7+
8+
async function execute () {
9+
const ws = new WSv2({
10+
apiKey,
11+
apiSecret,
12+
transform: true
13+
})
14+
ws.on('error', e => debug('WSv2 error: %s', e.message | e))
15+
await ws.open()
16+
await ws.auth()
617

7-
module.exports = runExample({
8-
name: 'ws2-sequencing',
9-
ws: { env: true, connect: true, auth: true }
10-
}, async ({ ws, debug }) => {
1118
// Enables internal sequence tracking; an error will be emitted if there is a
1219
// seq # mis-match
1320
await ws.enableSequencing({ audit: true })
@@ -39,4 +46,7 @@ module.exports = runExample({
3946
debug('recv public seq # %d, auth seq # %d', seq, authSeq)
4047
}
4148
})
42-
})
49+
await ws.close()
50+
}
51+
52+
execute()

0 commit comments

Comments
 (0)