Versions Compared

Key

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

...

Note: Hari had inserted the STOMP libraries into the project but is now using the npm command above. There may be some changes to the following

...


tools/config.ts

Adding STOMP Handler

...

Injecting STOMP Libraries

You can directly add to the library section of your source code e.g.:


Code Block
{src: `${this.ASSETS_SRC}/vendor-libs/js/amq_jquery_adapter.js`, inject: true, vendor: true},
{src: `${this.ASSETS_SRC}/vendor-libs/js/amq.js`, inject: true, vendor: true},
{src: `${this.ASSETS_SRC}/vendor-libs/js/stomp.js`, inject: true, vendor: true},


Subscribing to a Topic


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);
	}
);

...