Created
May 14, 2011 18:16
-
-
Save manuelzs/972475 to your computer and use it in GitHub Desktop.
Node.js + Socket.io + AMQP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(){}); | |
}); | |
Thank you. It's been fixed
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
Line 19 should be "};" :)