member_webapp/@overflow/noauth-probe/subscriber/noauth-probe.subscriber.ts

51 lines
1.5 KiB
TypeScript
Raw Normal View History

2018-05-10 10:54:47 +00:00
import { Injectable } from '@angular/core';
2018-05-31 13:11:23 +00:00
import { Observable, Subject } from 'rxjs';
2018-05-10 10:54:47 +00:00
2018-05-24 06:44:13 +00:00
import { RPCSubscriber } from '@loafer/ng-rpc';
import { LoggerService } from '@loafer/ng-logger';
2018-05-10 10:54:47 +00:00
2018-05-31 07:38:44 +00:00
import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
2018-05-10 10:54:47 +00:00
2018-05-31 13:11:23 +00:00
export interface NoAuthProbeNotify {
method: string;
params: NoAuthProbe;
}
export class NoAuthProbeSubscriberSubject extends Subject<NoAuthProbeNotify> {
}
2018-05-10 10:54:47 +00:00
@Injectable()
export class NoAuthProbeSubscriber {
2018-05-31 13:11:23 +00:00
private noAuthProbeSubscriberSubject: NoAuthProbeSubscriberSubject;
2018-05-10 10:54:47 +00:00
public constructor(
private loggerService: LoggerService,
) {
2018-06-20 07:00:24 +00:00
this.noAuthProbeSubscriberSubject = new NoAuthProbeSubscriberSubject();
2018-05-31 13:11:23 +00:00
}
public observable(): Observable<NoAuthProbeNotify> {
return this.noAuthProbeSubscriberSubject.asObservable();
}
private publish(method: string, params: any): void {
this.noAuthProbeSubscriberSubject.next({ method: method, params: params });
2018-05-10 10:54:47 +00:00
}
2018-06-20 07:00:24 +00:00
@RPCSubscriber({ method: 'NoAuthProbeService.onConnect' })
2018-05-10 10:54:47 +00:00
public onConnect(noAuthProbe: NoAuthProbe): void {
this.loggerService.debug('NoAuthProbeService.onConnect noAuthProbe:', noAuthProbe);
2018-05-31 13:11:23 +00:00
this.publish('NoAuthProbeService.onConnect', noAuthProbe);
2018-05-10 10:54:47 +00:00
}
2018-06-20 07:00:24 +00:00
@RPCSubscriber({ method: 'NoAuthProbeService.onDisconnect' })
2018-05-10 10:54:47 +00:00
public onDisconnect(noAuthProbe: NoAuthProbe): void {
this.loggerService.debug('NoAuthProbeService.onDisconnect noAuthProbe:', noAuthProbe);
2018-05-31 13:11:23 +00:00
this.publish('NoAuthProbeService.onDisconnect', noAuthProbe);
2018-05-10 10:54:47 +00:00
}
}