Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Setup your handler:

Code Block
languagejs



subscribeNotification() {
	this.loggedInZoneUuid = localStorage.getItem('zoneUuid');
	this.client = Stomp.client(Config.ACTIVEMQ_CLIENT);
	let topicUrl = '/topic/' + this.loggedInZoneUuid;
	let connectHeaders = {
		login: Config.ACTIVEMQ_USER_NAME,
		passcode: Config.ACTIVEMQ_PASSWORD,
		'client-id': this.loggedInZoneUuid
	};
	let componentRef = this;
	
	let callback = function (message) {
		// called when the client receives a STOMP message from the server
		componentRef.toastr.info(message.body);
		componentRef.incrementUnreadNotificationCount();
	};
	let subscribeHeaders = {'activemq.subscriptionName': this.loggedInZoneUuid};
	this.client.connect(connectHeaders, function () {
		componentRef.client.subscribe(topicUrl, callback, subscribeHeaders);
	}
);

...