import { Injectable } from '@angular/core'; import { Store, select } from '@ngrx/store'; import { RPCSubscriber } from '@loafer/ng-rpc/decorator'; import { LoggerService } from '@loafer/ng-logger/service'; import * as DiscoverStore from '../store/discover'; import { Zone, Host, Port, Service, } from '../model'; @Injectable() export class DiscoverySubscriber { public constructor( private store: Store, private loggerService: LoggerService, ) { } @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 { // this.loggerService.debug('DiscoverySubscriber.discoveredHost host:', host); 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)); } }