Skip to content

Instantly share code, notes, and snippets.

@m4tthumphrey
Last active August 29, 2015 13:57
Show Gist options
  • Save m4tthumphrey/9553977 to your computer and use it in GitHub Desktop.
Save m4tthumphrey/9553977 to your computer and use it in GitHub Desktop.
<?php
require dirname(__DIR__) . '/vendor/autoload.php';
$chat = new \MyApp\Chat();
$app = new \Ratchet\App();
$app->route('/test', $chat);
$app->run();
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs')
app.listen(8000);
function handler (req, res) {
console.log(req.url);
io.sockets.emit('news', { debug: 'boo'} );
res.writeHead(200);
res.end('boo');
}
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment