Skip to content

Instantly share code, notes, and snippets.

@cscchat
Forked from WietseWind/rippled-proxy.js
Last active April 2, 2018 20:07
Show Gist options
  • Save cscchat/2f21a887c6e1e7448e3fa55e75801b89 to your computer and use it in GitHub Desktop.
Save cscchat/2f21a887c6e1e7448e3fa55e75801b89 to your computer and use it in GitHub Desktop.
Casinocoin Websocket proxy to test reconnecting & health checking for https://www.npmjs.com/package/casinocoind-ws-client
const WebSocket = require('ws')
const ws = new WebSocket('wss://s1.casnocoin.org')
const wss = new WebSocket.Server({ port: 8011 })
wss.on('connection', function connection(c) {
let sendmessages = true
setTimeout(function () {
sendmessages = false
}, 20 * 1000)
c.on('message', function incoming(message) {
console.log('> %s', message)
if (sendmessages) ws.send(message)
})
c.on('close', function closed(r) {
console.log('close', r)
})
ws.on('message', function message(m) {
console.log('< %s', m)
c.send(m)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment