Modifying this so it moves buffers into string.

master
Alexander Blair 7 years ago
parent c9b0869e2c
commit a34e8c6ceb

@ -0,0 +1,19 @@
<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script>
<script>
// set-up a connection between the client and the server
var socket = io.connect('http://ftb-infinity.snipanet.com:8001/');
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "pool_stats";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
socket.on('message', function(data) {
console.log('Incoming message:', data);
});
</script>
</html>

@ -41,27 +41,7 @@ app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
if (cluster.isMaster) {
let numWorkers = require('os').cpus().length;
console.log('Master cluster setting up ' + numWorkers + ' workers...');
for (let i = 0; i < numWorkers; i++) {
let worker = cluster.fork();
workerList.push(worker);
}
cluster.on('online', function (worker) {
console.log('Worker ' + worker.process.pid + ' is online');
});
cluster.on('exit', function (worker, code, signal) {
console.log('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal);
console.log('Starting a new worker');
worker = cluster.fork();
workerList.push(worker);
});
} else {
server.listen(8001);
if (!cluster.isMaster) {
// Init the ZMQ listeners here.
sock.connect('tcp://127.0.0.1:3000');
sock.connect('tcp://127.0.0.1:3001');
@ -72,6 +52,21 @@ if (cluster.isMaster) {
sock.subscribe('');
}
require('sticky-cluster')(
// server initialization function
function (callback) {
// don't do server.listen(), just pass the server instance into the callback
callback(server);
},
// options
{
concurrency: require('os').cpus().length,
port: 8001,
debug: false,
env: function (index) { return { stickycluster_worker_index: index }; }
}
);
// SocketIO Routes
// ===============
io.on('connection', (socket) => {
@ -84,6 +79,8 @@ io.on('connection', (socket) => {
// The following is the ZMQ logic. Pray to whatever deity you like.
sock.on('message', function(topic, message) {
topic = topic.toString();
message = message.toString();
/*
Registered ZMQ Messages:
miner_hash_graph - Hash graphs updated

@ -38,6 +38,7 @@
"shapeshift.io": "1.3.0",
"socketio": "^1.0.0",
"sprintf-js": "^1.0.3",
"sticky-cluster": "^0.3.1",
"uuid": "3.0.1",
"wallet-address-validator": "0.1.0",
"zmq": "^2.15.3"

Loading…
Cancel
Save