Skip to content

Commit 650b87d

Browse files
author
Vitaliy Stoliarov
committed
update 'info_events' example
1 parent 5df2121 commit 650b87d

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

examples/ws2/info_events.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
'use strict'
22

3-
const runExample = require('../util/run_example')
3+
const { args: { apiKey, apiSecret }, debug } = require('../util/setup')
4+
const WSv2 = require('../../lib/transports/ws2')
5+
6+
async function execute () {
7+
const ws = new WSv2({
8+
apiKey,
9+
apiSecret,
10+
autoReconnect: true
11+
})
12+
ws.on('error', e => debug('WSv2 error: %s', e.message | e))
13+
await ws.open()
14+
await ws.auth()
415

5-
module.exports = runExample({
6-
name: 'ws2-info-events',
7-
ws: {
8-
env: true, connect: true, auth: true, autoReconnect: true
9-
}
10-
}, async ({ ws, debug }) => {
1116
ws.onMaintenanceStart(() => {
1217
debug('info: maintenance period started')
1318
// pause activity untill further notice
@@ -22,4 +27,7 @@ module.exports = runExample({
2227
debug('info: bitfinex ws server restarted')
2328
// await ws.reconnect() // if not using autoReconnect
2429
})
25-
})
30+
await ws.close()
31+
}
32+
33+
execute()

0 commit comments

Comments
 (0)