Created
September 7, 2012 14:27
-
-
Save brent-hoover/3666656 to your computer and use it in GitHub Desktop.
simple node.js event proxy that pipes rabbitmq messages to websockets
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
| class EventProxy | |
| @socket: null | |
| @amqp: null | |
| constructor: (socket, amqp) -> | |
| @socket = socket | |
| @amqp = amqp | |
| @amqp.on 'ready', @ready | |
| ready: => | |
| @amqp.queue '', @queue | |
| queue: (q) => | |
| q.bind 'events', '#' | |
| q.subscribe @emit | |
| emit: (message, headers, deliveryInfo) => | |
| @socket.emit deliveryInfo.routingKey, message | |
| new EventProxy(io.of('/events'), | |
| amqp.createConnection(config.amqp)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment