import { Injectable } from '@angular/core'; import { filter, tap } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { ProtocolService } from '@ucap-webmessenger/protocol'; import { SVC_TYPE_LOGOUT, SSVC_TYPE_LOGOUT_RES } from '@ucap-webmessenger/protocol-authentication'; import * as AuthenticationStore from '../store/account/authentication'; @Injectable() export class AppService { constructor( private protocolService: ProtocolService, private store: Store ) { this.protocolService.serverMessage .pipe( filter( res => res.serviceType === SVC_TYPE_LOGOUT && res.subServiceType === SSVC_TYPE_LOGOUT_RES ), tap(res => { this.store.dispatch(AuthenticationStore.logout()); }) ) .subscribe(); } public postInit(): Promise { return new Promise((resolve, reject) => { resolve(); }); } }