This commit is contained in:
crusader 2018-08-26 20:09:12 +09:00
parent f6834722b8
commit 6d74c96883
7 changed files with 50 additions and 24 deletions

View File

@ -39,7 +39,7 @@
"@ngrx/schematics": "^6.1.0", "@ngrx/schematics": "^6.1.0",
"@ngrx/store": "^6.1.0", "@ngrx/store": "^6.1.0",
"@ngrx/store-devtools": "^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/fs-extra": "^5.0.4",
"@types/jasmine": "~2.8.6", "@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",
@ -79,4 +79,4 @@
"webpack-node-externals": "^1.7.2", "webpack-node-externals": "^1.7.2",
"zone.js": "^0.8.26" "zone.js": "^0.8.26"
} }
} }

View File

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ElectronProxyService } from '../commons/service/electron-proxy.service'; import { ElectronProxyService } from '../commons/service/electron-proxy.service';
import { ProbeService } from '../commons/service/probe.service';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -12,11 +13,13 @@ export class AppComponent implements OnInit {
public constructor( public constructor(
private electronProxyService: ElectronProxyService, private electronProxyService: ElectronProxyService,
private probeService: ProbeService,
) { ) {
this.showTitleBar = !__LINUX__; this.showTitleBar = !__LINUX__;
} }
ngOnInit(): void { ngOnInit(): void {
this.probeService.connect();
this.electronProxyService.sendReady(performance.now()); this.electronProxyService.sendReady(performance.now());
} }
} }

View File

@ -10,6 +10,7 @@ import { AppStoreModule } from './app-store.module';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { CommonsModule } from '../commons/commons.module'; import { CommonsModule } from '../commons/commons.module';
import { SERVICES } from '../commons/service';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -26,7 +27,9 @@ import { CommonsModule } from '../commons/commons.module';
AppStoreModule, AppStoreModule,
], ],
providers: [], providers: [
...SERVICES,
],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule { }

View File

@ -5,7 +5,6 @@ import { CommonsUIModule } from '@overflow/commons/ui/commons-ui.module';
import { COMPONENTS } from './component'; import { COMPONENTS } from './component';
import { SERVICES } from './service';
@NgModule({ @NgModule({
imports: [ imports: [
@ -20,7 +19,6 @@ import { SERVICES } from './service';
...COMPONENTS, ...COMPONENTS,
], ],
providers: [ providers: [
...SERVICES,
] ]
}) })
export class CommonsModule { } export class CommonsModule { }

View File

@ -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({ @Component({
selector: 'app-nic-dropdown', selector: 'app-nic-dropdown',
templateUrl: './nic-dropdown.component.html', templateUrl: './nic-dropdown.component.html',
styleUrls: ['./nic-dropdown.component.scss'], styleUrls: ['./nic-dropdown.component.scss'],
}) })
export class NicDropdownComponent { export class NicDropdownComponent implements OnInit {
@Input() blockTarget: any; @Input() blockTarget: any;
constructor( constructor(
private probeService: ProbeService,
) { ) {
} }
ngOnInit(): void {
this.probeService.call<any>('MachineService.Interfaces').pipe(
map((ifaces: any) => {
console.log(ifaces);
}),
catchError(error => {
console.log(error);
return of();
}),
take(1),
).subscribe();
}
} }

View File

@ -2,26 +2,27 @@ import { Injectable } from '@angular/core';
import { import {
Client, Client,
ClientNotificationCodec, ClientNotificationCodec,
RxWebsocketRWC, WebSocketClientRWC,
RxWebsocketSubjectConfig, WebSocketClientRWCConfig,
JSONClientCodec JSONClientCodec
} from '@overflow/rpc-js'; } from '@overflow/rpc-js';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
@Injectable() const config: WebSocketClientRWCConfig = {
export class ProbeService { url: 'ws://localhost:60000/'
private probeClient: Client; };
const rwc = new WebSocketClientRWC(config);
const codec = new JSONClientCodec();
@Injectable({
providedIn: 'root'
})
export class ProbeService extends Client {
private notiSubscription: Subscription; private notiSubscription: Subscription;
public constructor() { public constructor() {
const config: RxWebsocketSubjectConfig<any> = { super(codec, rwc);
url: '' this.notiSubscription = this.notification()
};
const rwc = new RxWebsocketRWC(config);
const codec = new JSONClientCodec();
this.probeClient = new Client(codec, rwc);
this.notiSubscription = this.probeClient
.notification()
.subscribe((notiCodec: ClientNotificationCodec) => { .subscribe((notiCodec: ClientNotificationCodec) => {
console.log(notiCodec.method()); console.log(notiCodec.method());
}); });

View File

@ -224,10 +224,11 @@
tree-kill "^1.0.0" tree-kill "^1.0.0"
webpack-sources "^1.1.0" webpack-sources "^1.1.0"
"@overflow/rpc-js@0.0.4": "@overflow/rpc-js@0.0.11":
version "0.0.4" version "0.0.11"
resolved "https://nexus.loafle.net/repository/npm-all/@overflow/rpc-js/-/rpc-js-0.0.4.tgz#083577e4ca372c62bd8a529c29acca0163a1f6b6" resolved "https://nexus.loafle.net/repository/npm-all/@overflow/rpc-js/-/rpc-js-0.0.11.tgz#b73ede145d86d6517c7ed5e080e3e5bf4c757c3a"
dependencies: dependencies:
pako "^1.0.6"
rxjs "^6.2.2" rxjs "^6.2.2"
url-join "^4.0.0" url-join "^4.0.0"
@ -5104,7 +5105,7 @@ package-json@^4.0.0:
registry-url "^3.0.3" registry-url "^3.0.3"
semver "^5.1.0" 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" version "1.0.6"
resolved "https://nexus.loafle.net/repository/npm-all/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258" resolved "https://nexus.loafle.net/repository/npm-all/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"