How to send messages from php to node.js? I have a linux server running php and node.js.
When a user completes a transaction (via php), I\'d like send a message f
Step 1. Get the PHP Emitter: https://github.com/rase-/socket.io-php-emitter
$redis = new \Redis(); // Using the Redis extension provided client
$redis->connect('127.0.0.1', '6379');
$emitter = new SocketIO\Emitter($redis);
$emitter->emit('new question', 'h
tml');
add this to your index.js:
var redis = require('socket.io-redis');
io.adapter(redis({ host: 'localhost', port: 6379 }));
io.on('connection', function(socket){
socket.on('new question', function(msg) {
io.emit('new question', msg);
});
});
add something like this to your index.html
socket.on('new question', function(msg) {
$('body').append( msg );
});