Skip to content

Instantly share code, notes, and snippets.

@manuelzs
Created May 14, 2011 18:16
Show Gist options
  • Save manuelzs/972475 to your computer and use it in GitHub Desktop.
Save manuelzs/972475 to your computer and use it in GitHub Desktop.
Node.js + Socket.io + AMQP
var http = require('http');
var io = require('socket.io');
var sys = require('sys');
var amqp = require('amqp');
server = http.createServer(function(req, res){
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<h1>Hello world</h1>');
});
server.listen(81);
var connectionListener = function () {
var q = connection.queue('my-queue');
q.bind('#');
q.subscribe(function (message) {
sys.p(message);
});
};
var socket = io.listen(server);
socket.on('connection', function(client){
var connection = amqp.createConnection({ host: '127.0.0.1' });
connection.addListener('ready', connectionListener);
client.on('message', function(){});
client.on('disconnect', function(){});
});
@fatihpense
Copy link

Line 19 should be "};" :)

@manuelzs
Copy link
Author

Thank you. It's been fixed

@fatihpense
Copy link

Thank you for this example, it helped me to solve a problem. I'm new to node.js. Its logic is very different thus hard, however it is sympathetic :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment