member_webapp/@overflow/noauth-probe/subscriber/noauth-probe.subscriber.ts
crusader c1fa8fdb05 ing
2018-06-20 16:00:24 +09:00

51 lines
1.5 KiB
TypeScript

import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { RPCSubscriber } from '@loafer/ng-rpc';
import { LoggerService } from '@loafer/ng-logger';
import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
export interface NoAuthProbeNotify {
method: string;
params: NoAuthProbe;
}
export class NoAuthProbeSubscriberSubject extends Subject<NoAuthProbeNotify> {
}
@Injectable()
export class NoAuthProbeSubscriber {
private noAuthProbeSubscriberSubject: NoAuthProbeSubscriberSubject;
public constructor(
private loggerService: LoggerService,
) {
this.noAuthProbeSubscriberSubject = new NoAuthProbeSubscriberSubject();
}
public observable(): Observable<NoAuthProbeNotify> {
return this.noAuthProbeSubscriberSubject.asObservable();
}
private publish(method: string, params: any): void {
this.noAuthProbeSubscriberSubject.next({ method: method, params: params });
}
@RPCSubscriber({ method: 'NoAuthProbeService.onConnect' })
public onConnect(noAuthProbe: NoAuthProbe): void {
this.loggerService.debug('NoAuthProbeService.onConnect noAuthProbe:', noAuthProbe);
this.publish('NoAuthProbeService.onConnect', noAuthProbe);
}
@RPCSubscriber({ method: 'NoAuthProbeService.onDisconnect' })
public onDisconnect(noAuthProbe: NoAuthProbe): void {
this.loggerService.debug('NoAuthProbeService.onDisconnect noAuthProbe:', noAuthProbe);
this.publish('NoAuthProbeService.onDisconnect', noAuthProbe);
}
}