This commit is contained in:
crusader 2018-02-06 21:55:30 +09:00
parent cb7dc494f7
commit b02265ae78
6 changed files with 62 additions and 7 deletions

View File

@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';
import { RESTService } from './rest.service';
describe('RESTService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [RESTService]
});
});
it('should be created', inject([RESTService], (service: RESTService) => {
expect(service).toBeTruthy();
}));
});

View File

@ -0,0 +1,8 @@
import { Injectable } from '@angular/core';
@Injectable()
export class RESTService {
constructor() { }
}

View File

@ -1,19 +1,19 @@
import { TestBed, inject } from '@angular/core/testing';
import { APIService } from './api.service';
import { RPCService } from './rpc.service';
describe('APIService', () => {
describe('RPCService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [APIService]
providers: [RPCService]
});
});
it('should be created', inject([APIService], (service: APIService) => {
it('should be created', inject([RPCService], (service: RPCService) => {
expect(service).toBeTruthy();
}));
it('apiService connect to server', inject([APIService], (service: APIService) => {
it('apiService connect to server', inject([RPCService], (service: RPCService) => {
service.connect();
service.getConnectionStatus().subscribe(
(isConnected: boolean) => {

View File

@ -6,7 +6,7 @@ import { RPCRegistry } from 'app/core/rpc/registry/rpc-registry';
@Injectable()
export class APIService {
export class RPCService {
private wsSocketSubject: RxWebsocketSubject<Object>;
private rpcRegistry: RPCRegistry;
@ -37,6 +37,10 @@ export class APIService {
}
private sendData(data: Object): void {
this.wsSocketSubject.next(data);
}
public getConnectionStatus(): Observable<boolean> {
return this.wsSocketSubject.connectionStatus;
}

View File

@ -0,0 +1,28 @@
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { RPCRegistry } from '../registry/rpc-registry';
export class RPCClient {
private socketSubject: Subject<any>;
private rpcRegistry: RPCRegistry;
private pendingRequests: Map<number, Observable<any>>;
public constructor() {
}
public call<T>(method: string, ...args: any[]): Observable<T> {
return undefined;
}
public send(method: string, ...args: any[]): void {
}
private sendInternal(method: string, ...args: any[]): Observable<any> {
return undefined;
}
}

View File

@ -1,4 +1,4 @@
export interface ClientCodec {
writeRequest(method: string, args: any[], id?: number);
encode(method: string, args: any[], id?: number);
}