Skip to content
Snippets Groups Projects
Commit 2875a4fe authored by jojohoch's avatar jojohoch
Browse files

[player] Implement `vopGetStateRequest` subscription

parent 1dcfad9c
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ import { UnitPage } from '../../../../common/unit'; ...@@ -8,7 +8,7 @@ import { UnitPage } from '../../../../common/unit';
import { VeronaSubscriptionService } from '../services/verona-subscription.service'; import { VeronaSubscriptionService } from '../services/verona-subscription.service';
import { import {
PlayerState, PlayerState,
RunningState, VopContinueCommand, VopPageNavigationCommand, VopStopCommand RunningState, VopContinueCommand, VopGetStateRequest, VopPageNavigationCommand, VopStopCommand
} from '../models/verona'; } from '../models/verona';
import { VeronaPostService } from '../services/verona-post.service'; import { VeronaPostService } from '../services/verona-post.service';
...@@ -59,6 +59,9 @@ export class PlayerStateComponent implements OnInit, OnDestroy { ...@@ -59,6 +59,9 @@ export class PlayerStateComponent implements OnInit, OnDestroy {
this.veronaSubscriptionService.vopStopCommand this.veronaSubscriptionService.vopStopCommand
.pipe(takeUntil(this.ngUnsubscribe)) .pipe(takeUntil(this.ngUnsubscribe))
.subscribe((message: VopStopCommand): void => this.onStop(message)); .subscribe((message: VopStopCommand): void => this.onStop(message));
this.veronaSubscriptionService.vopGetStateRequest
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe((message: VopGetStateRequest): void => this.onGetStateRequest(message));
} }
onSelectedIndexChange(): void { onSelectedIndexChange(): void {
...@@ -79,6 +82,15 @@ export class PlayerStateComponent implements OnInit, OnDestroy { ...@@ -79,6 +82,15 @@ export class PlayerStateComponent implements OnInit, OnDestroy {
this.sendVopStateChangedNotification(); this.sendVopStateChangedNotification();
} }
private onGetStateRequest(message: VopGetStateRequest): void {
// eslint-disable-next-line no-console
console.log('player: onGetStateRequest', message);
if (message.stop) {
this.running = false;
}
this.sendVopStateChangedNotification();
}
private onPageNavigation(message: VopPageNavigationCommand): void { private onPageNavigation(message: VopPageNavigationCommand): void {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('player: onPageNavigation', message); console.log('player: onPageNavigation', message);
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { fromEvent, Observable, Subject } from 'rxjs'; import { fromEvent, Observable, Subject } from 'rxjs';
import { import {
VopContinueCommand, VopContinueCommand, VopGetStateRequest,
VopMessage, VopMessage,
VopNavigationDeniedNotification, VopNavigationDeniedNotification,
VopPageNavigationCommand, VopPageNavigationCommand,
...@@ -18,6 +18,7 @@ export class VeronaSubscriptionService { ...@@ -18,6 +18,7 @@ export class VeronaSubscriptionService {
private _vopPageNavigationCommand = new Subject<VopPageNavigationCommand>(); private _vopPageNavigationCommand = new Subject<VopPageNavigationCommand>();
private _vopStopCommand = new Subject<VopStopCommand>(); private _vopStopCommand = new Subject<VopStopCommand>();
private _vopContinueCommand = new Subject<VopContinueCommand>(); private _vopContinueCommand = new Subject<VopContinueCommand>();
private _vopGetStateRequest = new Subject<VopGetStateRequest>();
constructor() { constructor() {
fromEvent(window, 'message') fromEvent(window, 'message')
...@@ -39,7 +40,6 @@ export class VeronaSubscriptionService { ...@@ -39,7 +40,6 @@ export class VeronaSubscriptionService {
console.log('player: _vopNavigationDeniedNotification ', messageData); console.log('player: _vopNavigationDeniedNotification ', messageData);
this._vopNavigationDeniedNotification.next(messageData); this._vopNavigationDeniedNotification.next(messageData);
break; break;
// TODO
case 'vopPageNavigationCommand': case 'vopPageNavigationCommand':
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('player: _vopPageNavigationCommand ', messageData); console.log('player: _vopPageNavigationCommand ', messageData);
...@@ -56,6 +56,10 @@ export class VeronaSubscriptionService { ...@@ -56,6 +56,10 @@ export class VeronaSubscriptionService {
this._vopContinueCommand.next(messageData); this._vopContinueCommand.next(messageData);
break; break;
case 'vopGetStateRequest': case 'vopGetStateRequest':
// eslint-disable-next-line no-console
console.log('player: _vopGetStateRequest ', messageData);
this._vopGetStateRequest.next(messageData);
break;
default: default:
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.warn(`player: got message of unknown type ${messageData.type}`); console.warn(`player: got message of unknown type ${messageData.type}`);
...@@ -81,4 +85,8 @@ export class VeronaSubscriptionService { ...@@ -81,4 +85,8 @@ export class VeronaSubscriptionService {
get vopContinueCommand(): Observable<VopContinueCommand> { get vopContinueCommand(): Observable<VopContinueCommand> {
return this._vopContinueCommand.asObservable(); return this._vopContinueCommand.asObservable();
} }
get vopGetStateRequest(): Observable<VopGetStateRequest> {
return this._vopGetStateRequest.asObservable();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment