Setup:
cp config/http.conf.json.example config/http.conf.json
cp config/ws.conf.json.example config/ws.conf.json
Start with:
node start-ws-proxy.js
There is an example in ./example-ws-proxy.js.
The websocket server mimics the bfx v2 api. For order book updates it polls the hive gateway. It keeps a local copy to send order book updates next to snapshots.
To setup two users (user id 1
and 2
), give them wallet balances and put a few orders into the orderbook, run:
node example-ws-proxy.js
Start with:
node start-http-proxy.js
There is an example in ./example-http-proxy.js - this will create two users and submit two matching oders for them. Finally, it will print the updated user wallet balances.
Features of socket.js
:
- caches ZMQ sockets
- adds new sockets on the fly
Example:
const Sock = require('./')
const s = new Sock({
gateway: 'ipc:///tmp/proxy0'
})
s.send('gateway', ['set_gw_status', {'trigger_tickers': true, 'trigger_liq': true}])
See more advanced examples in ./example-socket.js
Creates new instance
Sends data to a ZMQ endpoint. Serializes JSON.
Closes all sockets (no argument) or a specfic socket.