Skip to content

Commit

Permalink
Topic emits (un)registered events.
Browse files Browse the repository at this point in the history
registered_subscriber / unregistered_subscriber (and _publisher) are emitted
when registered or unregistered with master.
  • Loading branch information
baalexander committed Apr 25, 2012
1 parent 1ac8491 commit 1cd4bcf
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions lib/topic.js
Expand Up @@ -140,15 +140,18 @@ Topic.prototype.publish = function(message) {

this.getUri(function(uri) {
var masterParams = {
callerId : that.node
, callerUri : uri
, topic : that.topic
, messageType : that.messageType.messageType
callerId : that.node
, callerUri : uri
, topic : that.topic
, messageType : that.messageType.messageType
};
master.registerPublisher(masterParams, function(error) {
if (error) {
that.emit('error', error);
}
else {
that.emit('registered_publisher');
}
});
});
}
Expand All @@ -160,9 +163,9 @@ Topic.prototype.unpublish = function(message) {
if (this.protocol) {
this.getUri(function(uri) {
var masterParams = {
callerId : that.node
, callerUri : uri
, topic : that.topic
callerId : that.node
, callerUri : uri
, topic : that.topic
};
master.unregisterPublisher(masterParams, function(error) {
if (error) {
Expand All @@ -184,15 +187,18 @@ Topic.prototype.subscribe = function(callback) {
if (!this.protocol) {
this.getUri(function(uri) {
var masterParams = {
callerId : that.node
, callerUri : uri
, topic : that.topic
, messageType : that.messageType.messageType
callerId : that.node
, callerUri : uri
, topic : that.topic
, messageType : that.messageType.messageType
};
master.registerSubscriber(masterParams, function(error) {
if (error) {
that.emit('error', error);
}
else {
that.emit('registered_subscriber');
}
});
});
}
Expand All @@ -204,9 +210,9 @@ Topic.prototype.unsubscribe = function(callback) {
if (this.protocol) {
this.getUri(function(uri) {
var masterParams = {
callerId : that.node
, callerUri : uri
, topic : that.topic
callerId : that.node
, callerUri : uri
, topic : that.topic
};
master.unregisterSubscriber(masterParams, function(error) {
if (error) {
Expand Down

0 comments on commit 1cd4bcf

Please sign in to comment.