socket.io-amqp
Advanced tools
Comparing version 0.3.1 to 0.3.2
15
index.js
@@ -68,2 +68,3 @@ /* | ||
queueName: '', | ||
channelSeperator: '#', | ||
prefix: '' | ||
@@ -151,3 +152,3 @@ }); | ||
self.globalRoomName = prefix + '#' + self.nsp.name + '#'; | ||
self.globalRoomName = getChannelName(prefix, self.nsp.name); | ||
amqpChannel.bindQueue(self.amqpIncomingQueue, self.amqpExchangeName, self.globalRoomName, {}, function (err) | ||
@@ -267,3 +268,3 @@ { | ||
Adapter.prototype.add.call(self, id, room); | ||
var channel = prefix + '#' + self.nsp.name + '#' + room + '#'; | ||
var channel = getChannelName(prefix, self.nsp.name, room); | ||
@@ -308,3 +309,3 @@ if (needToSubscribe) | ||
{ | ||
var chn = prefix + '#' + packet.nsp + '#' + room + '#'; | ||
var chn = getChannelName(prefix, packet.nsp, room); | ||
var msg = msgpack.encode([self.amqpConsumerID, packet, opts]); | ||
@@ -342,3 +343,3 @@ amqpChannel.publish(self.amqpExchangeName, chn, msg); | ||
{ | ||
var channel = prefix + '#' + self.nsp.name + '#' + room + '#'; | ||
var channel = getChannelName(prefix, self.nsp.name, room); | ||
@@ -401,3 +402,3 @@ amqpChannel.unbindQueue(self.amqpIncomingQueue, self.amqpExchangeName, channel, {}, function (err) | ||
{ | ||
var channel = prefix + '#' + self.nsp.name + '#' + room + '#'; | ||
var channel = getChannelName(prefix, self.nsp.name, room); | ||
@@ -441,4 +442,8 @@ amqpChannel.unbindQueue(self.amqpIncomingQueue, self.amqpExchangeName, channel, {}, function (err) | ||
function getChannelName() { | ||
return Array.prototype.join.call(arguments, opts.channelSeperator) + opts.channelSeperator; | ||
} | ||
return AMQPAdapter; | ||
} |
{ | ||
"name": "socket.io-amqp", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "A Sockets.IO Adapter for AMQP & RabbitMQ", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
@@ -26,2 +26,6 @@ # socket.io-amqp | ||
- `queueName`: The name of the rabbitmq queue to use listen in on the exchange. Must be unique. Default value is '' which means rabbitmq will auto generate a queue name for you that is unique. | ||
- `channelSeperator`: The delimiter between the prefix, the namespace name, and the room, the default is '#' for compatibility with socket.io-emitter, but if you don't use it,**you should change it because # is a wildcard character in rabbitmq which means you may get cross chatter with other rooms**. | ||
- `onNamespaceInitializedCallback`: This is a callback function that is called everytime sockets.io opens a new namespace. Because a new namespace requires new queues and exchanges, you can get a callback to indicate the success or failure here. This callback should be in the form of function(err, nsp), where err is the error, and nsp is the namespace. If your code needs to wait until sockets.io is fully set up and ready to go, you can use this. | ||
@@ -28,0 +32,0 @@ |
Sorry, the diff of this file is not supported yet
27955
488
35