member_webapp/@overflow/discovery/subscriber/discovery.subscriber.ts

62 lines
2.0 KiB
TypeScript
Raw Normal View History

2018-04-06 11:02:18 +00:00
import { Injectable } from '@angular/core';
import { Store, select } from '@ngrx/store';
2018-05-24 06:44:13 +00:00
import { RPCSubscriber } from '@loafer/ng-rpc';
import { LoggerService } from '@loafer/ng-logger';
2018-04-06 11:02:18 +00:00
import * as DiscoverStore from '../store/discover';
import {
Zone,
Host,
Port,
Service,
2018-05-02 07:23:35 +00:00
} from '@overflow/commons-typescript/model/discovery';
2018-04-06 11:02:18 +00:00
@Injectable()
export class DiscoverySubscriber {
public constructor(
private store: Store<DiscoverStore.State>,
private loggerService: LoggerService,
) {
}
2018-04-19 15:15:20 +00:00
@RPCSubscriber({method: 'DiscoveryService.discoveryStart'})
public discoveryStart(startDate: Date): void {
this.loggerService.debug('DiscoverySubscriber.discoveryStart startDate:', startDate);
this.store.dispatch(new DiscoverStore.DiscoveryStart(startDate));
}
@RPCSubscriber({method: 'DiscoveryService.discoveryStop'})
public discoveryStop(stopDate: Date): void {
this.loggerService.debug('DiscoverySubscriber.discoveryStop stopDate:', stopDate);
this.store.dispatch(new DiscoverStore.DiscoveryStop(stopDate));
}
2018-04-06 11:02:18 +00:00
@RPCSubscriber({method: 'DiscoveryService.discoveredZone'})
public discoveredZone(zone: Zone): void {
this.loggerService.debug('DiscoverySubscriber.discoveredZone zone:', zone);
this.store.dispatch(new DiscoverStore.DiscoveredZone(zone));
}
@RPCSubscriber({method: 'DiscoveryService.discoveredHost'})
public discoveredHost(host: Host): void {
2018-04-19 15:15:20 +00:00
this.loggerService.debug('DiscoverySubscriber.discoveredHost host:', host);
2018-04-06 11:02:18 +00:00
this.store.dispatch(new DiscoverStore.DiscoveredHost(host));
}
@RPCSubscriber({method: 'DiscoveryService.discoveredPort'})
public discoveredPort(port: Port): void {
this.store.dispatch(new DiscoverStore.DiscoveredPort(port));
}
@RPCSubscriber({method: 'DiscoveryService.discoveredService'})
public discoveredService(service: Service): void {
this.loggerService.debug('DiscoverySubscriber.discoveredService service:', service);
this.store.dispatch(new DiscoverStore.DiscoveredService(service));
}
}