Skip to content

Instantly share code, notes, and snippets.

@lholmquist
Created June 18, 2013 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lholmquist/5808071 to your computer and use it in GitHub Desktop.
Save lholmquist/5808071 to your computer and use it in GitHub Desktop.
//creating a stompws noftifier, is we add the channels here, there is a connection error
notifierStomp = AeroGear.Notifier({
name: "stompClient",
type: "stompws",
settings: {
connectURL: "ws://localhost:61614/stomp",
channels: [ stompChannel ]
}
});
//Basically, the subscribe methods is called with the reset option as true,
//so unsubscribe is called, which removes the channels from the channels array, so after this, there are no channels to register
AeroGear.Notifier.adapters.stompws.prototype.subscribe = function( channels, reset ) {
var client = this.getClient();
if ( reset ) {
this.unsubscribe( this.getChannels() );
}
channels = AeroGear.isArray( channels ) ? channels : [ channels ];
for ( var i = 0; i < channels.length; i++ ) {
channels[ i ].id = client.subscribe( channels[ i ].address, channels[ i ].callback );
this.addChannel( channels[ i ] );
}
};
AeroGear.Notifier.adapters.stompws.prototype.unsubscribe = function( channels ) {
var client = this.getClient();
channels = AeroGear.isArray( channels ) ? channels : [ channels ];
for ( var i = 0; i < channels.length; i++ ) {
client.unsubscribe( channels[ i ].id );
this.removeChannel( channels[ i ] );
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment