I am building an app using nodeJS along with socket io . I have a server.js file in which i did the following :
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
io.on('connection', function(socket){
console.log("a user is connected");
});
Also i have another file "api.js" in which i have the following function :
filter.watch(function(error, result){
if (!error){
var newblock = new Block(web3.eth.getBlock(result));
newblock.save(function (err) {
if (err) return handleError(err);
// saved!
})
}
});
Im trying to send the object "newblock" (which is changing constantly) from the file api.js to server.js with socket io . I tried doing " socket.emit('fromApi_toserver',newblock)" in api.js but it's not working... Does anyone have any ideas ?
via Sarah
No comments:
Post a Comment