I've got the following config:
app.set('port', process.env.PORT || 3000); var httpserver = http.createServer(app).listen(app.get('port'), function(){ console.log('Express server listening on port ' + app.get('port')); }); var io = require('socket.io')(httpserver); app.all('/blockcallback', function(req, res){ res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "X-Requested-With"); getTxSender(req.query.tx,function(ref_wallet){ (..) }); io.emit('status', {'message': 'done'}); res.send('*ok*'); }); index.html
<script src="http://localhost:3000/socket.io/socket.io.js"></script> <script> var socket = io.connect('http://localhost:3000'); socket.on('status', function(datos){ alert('received'); }); </script> ok when i call http://localhost:3000/blockcallback looks like everything works perfectly, but i am not getting the 'status' call on the clientside.
my js console shows:
Error in event handler for extension.onRequest: undefined Stack trace: undefined localhost/:1 Error in event handler for extension.onRequest: undefined Stack trace: undefined extensions::uncaught_exception_handler:9 Stack trace: undefined extensions::uncaught_exception_handler:9 I don't understand what's happening...
Regards,
io.emit()who are you trying to send to? All connected users? Only the user making the request? Also, do you realize that the way your code is structured, neitherio.emit()norres.end("*ok*")are waiting untilgetTxSender()is done?