import { Injectable, Inject } from '@angular/core';
import { Store, select } from '@ngrx/store';

import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';

import {
  RPC_CODEC,
  RPC_RWC,
} from '../core';

import {
  RPCClient,
  RPCClientRWC,
} from '../client';

import {
  RPCClientCodec,
  RPCClientNotificationCodec,
} from '../protocol';

import {
  RPCSubscribeService,
} from '../subscribe';

@Injectable()
export class RPCService extends RPCClient {
  constructor(
    @Inject(RPC_CODEC) rpcClientCodec: RPCClientCodec,
    @Inject(RPC_RWC) rpcClientRWC: RPCClientRWC,
    private rpcSubscribeService: RPCSubscribeService,
  ) {
    super(rpcClientCodec, rpcClientRWC);
  }

  protected onNotification(notiCodec: RPCClientNotificationCodec): void {
    this.rpcSubscribeService.notify(notiCodec);
  }
}
