From 6d74c9688343953441f98c95cf03c7bac3bd82fc Mon Sep 17 00:00:00 2001 From: crusader Date: Sun, 26 Aug 2018 20:09:12 +0900 Subject: [PATCH] ing --- package.json | 4 +-- src/app/app.component.ts | 3 +++ src/app/app.module.ts | 5 +++- src/commons/commons.module.ts | 2 -- .../component/nic-dropdown.component.ts | 24 +++++++++++++++-- src/commons/service/probe.service.ts | 27 ++++++++++--------- yarn.lock | 9 ++++--- 7 files changed, 50 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 018301a..5128d4f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@ngrx/schematics": "^6.1.0", "@ngrx/store": "^6.1.0", "@ngrx/store-devtools": "^6.1.0", - "@overflow/rpc-js": "0.0.4", + "@overflow/rpc-js": "0.0.11", "@types/fs-extra": "^5.0.4", "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", @@ -79,4 +79,4 @@ "webpack-node-externals": "^1.7.2", "zone.js": "^0.8.26" } -} +} \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index af0af72..513be73 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { ElectronProxyService } from '../commons/service/electron-proxy.service'; +import { ProbeService } from '../commons/service/probe.service'; @Component({ selector: 'app-root', @@ -12,11 +13,13 @@ export class AppComponent implements OnInit { public constructor( private electronProxyService: ElectronProxyService, + private probeService: ProbeService, ) { this.showTitleBar = !__LINUX__; } ngOnInit(): void { + this.probeService.connect(); this.electronProxyService.sendReady(performance.now()); } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index cdf0bea..3090f7b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -10,6 +10,7 @@ import { AppStoreModule } from './app-store.module'; import { AppComponent } from './app.component'; import { CommonsModule } from '../commons/commons.module'; +import { SERVICES } from '../commons/service'; @NgModule({ declarations: [ @@ -26,7 +27,9 @@ import { CommonsModule } from '../commons/commons.module'; AppStoreModule, ], - providers: [], + providers: [ + ...SERVICES, + ], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/src/commons/commons.module.ts b/src/commons/commons.module.ts index db2701e..a6eec5b 100644 --- a/src/commons/commons.module.ts +++ b/src/commons/commons.module.ts @@ -5,7 +5,6 @@ import { CommonsUIModule } from '@overflow/commons/ui/commons-ui.module'; import { COMPONENTS } from './component'; -import { SERVICES } from './service'; @NgModule({ imports: [ @@ -20,7 +19,6 @@ import { SERVICES } from './service'; ...COMPONENTS, ], providers: [ - ...SERVICES, ] }) export class CommonsModule { } diff --git a/src/commons/component/nic-dropdown.component.ts b/src/commons/component/nic-dropdown.component.ts index 0184fe0..7eca74a 100644 --- a/src/commons/component/nic-dropdown.component.ts +++ b/src/commons/component/nic-dropdown.component.ts @@ -1,15 +1,35 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; + +import { Observable, Subscription, of } from 'rxjs'; +import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators'; + + +import { ProbeService } from '../service/probe.service'; @Component({ selector: 'app-nic-dropdown', templateUrl: './nic-dropdown.component.html', styleUrls: ['./nic-dropdown.component.scss'], }) -export class NicDropdownComponent { +export class NicDropdownComponent implements OnInit { @Input() blockTarget: any; constructor( + private probeService: ProbeService, ) { } + + ngOnInit(): void { + this.probeService.call('MachineService.Interfaces').pipe( + map((ifaces: any) => { + console.log(ifaces); + }), + catchError(error => { + console.log(error); + return of(); + }), + take(1), + ).subscribe(); + } } diff --git a/src/commons/service/probe.service.ts b/src/commons/service/probe.service.ts index cfc65f3..a26cf1f 100644 --- a/src/commons/service/probe.service.ts +++ b/src/commons/service/probe.service.ts @@ -2,26 +2,27 @@ import { Injectable } from '@angular/core'; import { Client, ClientNotificationCodec, - RxWebsocketRWC, - RxWebsocketSubjectConfig, + WebSocketClientRWC, + WebSocketClientRWCConfig, JSONClientCodec } from '@overflow/rpc-js'; import { Subscription } from 'rxjs'; -@Injectable() -export class ProbeService { - private probeClient: Client; +const config: WebSocketClientRWCConfig = { + url: 'ws://localhost:60000/' +}; +const rwc = new WebSocketClientRWC(config); +const codec = new JSONClientCodec(); + +@Injectable({ + providedIn: 'root' +}) +export class ProbeService extends Client { private notiSubscription: Subscription; public constructor() { - const config: RxWebsocketSubjectConfig = { - url: '' - }; - const rwc = new RxWebsocketRWC(config); - const codec = new JSONClientCodec(); - this.probeClient = new Client(codec, rwc); - this.notiSubscription = this.probeClient - .notification() + super(codec, rwc); + this.notiSubscription = this.notification() .subscribe((notiCodec: ClientNotificationCodec) => { console.log(notiCodec.method()); }); diff --git a/yarn.lock b/yarn.lock index ca56938..2430aaa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -224,10 +224,11 @@ tree-kill "^1.0.0" webpack-sources "^1.1.0" -"@overflow/rpc-js@0.0.4": - version "0.0.4" - resolved "https://nexus.loafle.net/repository/npm-all/@overflow/rpc-js/-/rpc-js-0.0.4.tgz#083577e4ca372c62bd8a529c29acca0163a1f6b6" +"@overflow/rpc-js@0.0.11": + version "0.0.11" + resolved "https://nexus.loafle.net/repository/npm-all/@overflow/rpc-js/-/rpc-js-0.0.11.tgz#b73ede145d86d6517c7ed5e080e3e5bf4c757c3a" dependencies: + pako "^1.0.6" rxjs "^6.2.2" url-join "^4.0.0" @@ -5104,7 +5105,7 @@ package-json@^4.0.0: registry-url "^3.0.3" semver "^5.1.0" -pako@~1.0.2, pako@~1.0.5: +pako@^1.0.6, pako@~1.0.2, pako@~1.0.5: version "1.0.6" resolved "https://nexus.loafle.net/repository/npm-all/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"