Update services according to the new API

This commit is contained in:
R. Richard
2019-08-07 10:28:48 +02:00
parent a254e27fbf
commit 6b25416973
6 changed files with 28 additions and 31 deletions

View File

@ -3,25 +3,20 @@
import { Injectable } from '@angular/core';
import { WebSocketService } from './websocket.service';
import { LogMessage } from '../message-types/log-message';
import { ProcessLogCommand } from '../message-types/process-log-command';
import { config } from '../config';
import { BehaviorSubject } from 'rxjs';
import { LogMessage } from '../message-types/log-message';
import { CommandMessage } from '../message-types/command-message';
@Injectable()
export class ProcessLogService {
newLogs = new BehaviorSubject<LogMessage>(config.console.defaultLogs);
showLiveLogs = config.console.showLiveLogs;
command_handlers = {
'new_log': this.newLogsHandler.bind(this)
};
constructor(private webSocketService: WebSocketService) {
this.webSocketService.connect();
this.webSocketService.observeKey<CommandMessage>('processlog').subscribe(
(event) => this.command_handlers[event.data.command](event.data)
this.webSocketService.observeKey<ProcessLogCommand>('log.new').subscribe(
(event) => this.newLogsHandler(event)
);
}