2019-09-19 10:40:16 +09:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
2019-09-19 17:03:39 +09:00
|
|
|
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';
|
|
|
|
|
2019-09-19 10:40:16 +09:00
|
|
|
@Injectable()
|
|
|
|
export class AppService {
|
2019-09-19 17:03:39 +09:00
|
|
|
constructor(
|
|
|
|
private protocolService: ProtocolService,
|
|
|
|
private store: Store<any>
|
|
|
|
) {
|
|
|
|
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();
|
|
|
|
}
|
2019-09-19 10:40:16 +09:00
|
|
|
|
|
|
|
public postInit(): Promise<void> {
|
|
|
|
return new Promise<void>((resolve, reject) => {
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|