...
Setup your handler:
Code Block | ||
---|---|---|
| ||
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);
}
); |
...