unsubscribe() {
   // can be null when session loading fails (e.g. expired token)
   if (this.wsSubject$) {
     this.wsSubject$.unsubscribe();
   }
   // topic is used as a flag for cancelling the reconnection
   this.topic = null;
 }
Exemple #2
0
 on(communication: Communication, callback: (event: CommunicationEvent) => any) {
     this.eventStream.subscribe((event: CommunicationEvent) => {
         if(event.name === communication.getName()) {
             callback(event)
         }
     });
     return this;
 }
Exemple #3
0
 send(data: CommunicationEvent) {
     this.eventStream.next(data);
 }
Exemple #4
0
 constructor() {
     this.eventStream = WebSocketSubject.create<CommunicationEvent>(`ws://${location.hostname}:8080`);
 }