Hi I'm trying to emit events from PHP to a socketio server. I've tried both these forks:
https://github.com/rase-/socket.io-php-emitter
https://github.com/ashiina/socket.io-php-emitter
PHP code:
<?php
require_once( 'socketio/src/Emitter.php' );
$emitter = new SocketIO\Emitter( array( 'port' => '6379', 'host' => '127.0.0.1') );
$emitter->broadcast->emit( 'testcall', 'data' );
?>
package.json:
{
"name": "Emitter",
"devDependencies": {
"express": "~4.13.4",
"socket.io": "~1.7.3",
"socket.io-redis": "~4.0.0"
}
}
Node server:
var app = require( 'express' )( ),
http = require( 'http' ).Server( app ),
io = require('socket.io')( http ),
redis = require( 'socket.io-redis' );
http.listen( 8081, function( ) {
console.log( '\n==========================' );
console.log( 'server listening on *:8081' );
console.log( '==========================\n' );
});
io.adapter( redis({ host: '127.0.0.1', port: 6379 }) );
io.on( 'connection', function( socket ) {
socket.on( 'testcall', function( ) {
console.log( 'testcall' );
});
});
I have redis-cli monitor open and I can see it publishing data to redis but I never see the log appear. I can emit events from a browser but the PHP ones never appear.
Any ideas what I'm doing wrong?