-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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