ing
This commit is contained in:
parent
cb7dc494f7
commit
b02265ae78
15
src/app/commons/service/rest.service.spec.ts
Normal file
15
src/app/commons/service/rest.service.spec.ts
Normal 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();
|
||||
}));
|
||||
});
|
8
src/app/commons/service/rest.service.ts
Normal file
8
src/app/commons/service/rest.service.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class RESTService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
}
|
|
@ -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) => {
|
|
@ -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;
|
||||
}
|
28
src/app/core/rpc/client/rpc-client.ts
Normal file
28
src/app/core/rpc/client/rpc-client.ts
Normal 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;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
export interface ClientCodec {
|
||||
writeRequest(method: string, args: any[], id?: number);
|
||||
encode(method: string, args: any[], id?: number);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user