Created
June 18, 2013 18:40
-
-
Save lholmquist/5808071 to your computer and use it in GitHub Desktop.
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
//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