From 69535f452dace6c4c15fef6873821181aca5b5d2 Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 6 Sep 2018 00:13:31 +0900 Subject: [PATCH] ing --- .../commons/ui/decorator/RPCSubscriber.ts | 12 +--- package.json | 6 +- src/app/pages/home/home-page.component.ts | 24 +------ src/commons/service/probe.service.ts | 63 +------------------ yarn.lock | 14 +++-- 5 files changed, 19 insertions(+), 100 deletions(-) diff --git a/@overflow/commons/ui/decorator/RPCSubscriber.ts b/@overflow/commons/ui/decorator/RPCSubscriber.ts index 756d7cb..289ed2e 100644 --- a/@overflow/commons/ui/decorator/RPCSubscriber.ts +++ b/@overflow/commons/ui/decorator/RPCSubscriber.ts @@ -1,7 +1,5 @@ import { - Type, PropertyKeyType, - Annotation, DecoratorHelper, } from '@overflow/core-js'; @@ -19,14 +17,10 @@ export function RPCSubscriber(attribute: RPCSubscriberDecoratorAttribute): Metho } // import { -// Type, // PropertyKeyType, -// } from '@loafer/core'; - -// import { // Decorator, -// DecoratorFactory, -// } from '@loafer/decorator'; +// DecoratorHelper +// } from '@overflow/core-js'; // export interface RPCSubscriberDecoratorAttribute { // method: string; @@ -43,4 +37,4 @@ export function RPCSubscriber(attribute: RPCSubscriberDecoratorAttribute): Metho // } -// export const RPCSubscriber = DecoratorFactory.create(RPCSubscriberDecorator); +// export const RPCSubscriber = DecoratorHelper.create(RPCSubscriberDecorator); diff --git a/package.json b/package.json index b250426..473d480 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,8 @@ "@ngrx/schematics": "^6.1.0", "@ngrx/store": "^6.1.0", "@ngrx/store-devtools": "^6.1.0", - "@overflow/core-js": "0.0.6", - "@overflow/rpc-js": "0.0.5", + "@overflow/core-js": "0.0.7", + "@overflow/rpc-js": "0.0.7", "@types/fs-extra": "^5.0.4", "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", @@ -83,4 +83,4 @@ "webpack-node-externals": "^1.7.2", "zone.js": "^0.8.26" } -} +} \ No newline at end of file diff --git a/src/app/pages/home/home-page.component.ts b/src/app/pages/home/home-page.component.ts index 7a7ad8f..853172e 100644 --- a/src/app/pages/home/home-page.component.ts +++ b/src/app/pages/home/home-page.component.ts @@ -67,26 +67,6 @@ export class HomePageComponent implements OnInit { }; this.probeService.send('DiscoveryService.DiscoverHost', requesterID, zone, discoverHost); - - // this.probeService.call('MachineService.Interfaces').pipe( - // map((ifaces: Interface[]) => { - // console.log(ifaces); - // this.addresses = []; - // ifaces.forEach(iface => { - // iface.addresses.forEach(address => { - // this.addresses.push({ - // label: address.address, - // value: address.address, - // }); - // }); - // }); - // }), - // catchError(error => { - // console.log(error); - // return of(); - // }), - // take(1), - // ).subscribe(); } /** @@ -125,8 +105,8 @@ export class HomePageComponent implements OnInit { * DiscoverHost */ @RPCSubscriber({ method: 'DiscoveryService.DiscoveryStop' }) - public DiscoveryStop(elapsed: number) { - console.log('DiscoveryStop', elapsed); + public DiscoveryStop(stopDate: Date) { + console.log('DiscoveryStop', stopDate); } /** diff --git a/src/commons/service/probe.service.ts b/src/commons/service/probe.service.ts index 4774240..fbb3adf 100644 --- a/src/commons/service/probe.service.ts +++ b/src/commons/service/probe.service.ts @@ -7,7 +7,7 @@ import { JSONClientCodec } from '@overflow/rpc-js'; import { Subscription } from 'rxjs'; -import { TypeUtil, Class, Annotation, PropertyKeyType, Method } from '@overflow/core-js'; +import { TypeUtil, Class, Annotation, PropertyKeyType, Method, ReflectionUtil } from '@overflow/core-js'; import { RPCSubscriberDecoratorAttribute } from '@overflow/commons/ui/decorator/RPCSubscriber'; export const requesterID = 'scannerUser'; @@ -71,7 +71,7 @@ export class ProbeService extends Client { } subscriberMethods.forEach((subscriberMethod) => { try { - const args = this.converParams(params, subscriberMethod.parameterTypes); + const args = this.converNotificationParams(params, subscriberMethod.parameterTypes); subscriberMethod.method.invoke(subscriberMethod.instance, ...args); } catch (error) { console.error(error); @@ -122,7 +122,7 @@ export class ProbeService extends Client { this.subscriberMethodMap.set(subscriberMethodName, subscriberMethods); } - const paramTypes = this.getParamTypes(method); + const paramTypes = ReflectionUtil.getParamTypeStrings(method); const subscriberMethod: SubscriberMethod = { className: clazz.getName(), @@ -160,61 +160,4 @@ export class ProbeService extends Client { }); } - private getParamTypes(method: Method): string[] { - if (undefined === method || null === method || 0 === method.getParameterCount()) { - return []; - } - - const parameters = method.getParameters(); - const results: string[] = []; - for (let indexI = 0; indexI < parameters.length; indexI++) { - const paramType = parameters[indexI].getType(); - results.push(paramType.name); - } - return results; - } - - private converParams(params: string[], paramTypes: string[]): any[] { - const results: any[] = []; - - if (undefined === params || null === params || 0 === params.length) { - return results; - } - if (undefined === paramTypes || null === paramTypes || 0 === paramTypes.length) { - return results; - } - if (params.length !== paramTypes.length) { - throw new SubscriberParameterError(`Count is not same from server[${params.length}] and method[${paramTypes.length}]`); - } - for (let indexI = 0; indexI < params.length; indexI++) { - const param = params[indexI]; - const type = paramTypes[indexI]; - switch (type) { - case 'Object': - case 'Array': - case 'Map': - results.push(JSON.parse(param)); - break; - case 'String': - results.push(param); - break; - case 'Number': - results.push(Number(param)); - break; - case 'Boolean': - results.push(Boolean(param)); - break; - case 'Date': - results.push(new Date(Number(param))); - break; - case 'Function': - throw new SubscriberParameterError(`Function type [${indexI}] is not allowed`); - default: - throw new SubscriberParameterError(`${type} type parameter[${indexI}] is not allowed`); - } - } - return results; - } - - } diff --git a/yarn.lock b/yarn.lock index a26544a..813147b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -224,15 +224,17 @@ tree-kill "^1.0.0" webpack-sources "^1.1.0" -"@overflow/core-js@0.0.6": - version "0.0.6" - resolved "https://nexus.loafle.net/repository/npm-all/@overflow/core-js/-/core-js-0.0.6.tgz#432be1ef1b561cd802b261b6b73c5b9a71570aa3" +"@overflow/core-js@0.0.7", "@overflow/core-js@^0.0.7": + version "0.0.7" + resolved "https://nexus.loafle.net/repository/npm-all/@overflow/core-js/-/core-js-0.0.7.tgz#07463557b77d967a011d2f7f6a6f7ab5b2df9252" dependencies: reflect-metadata "^0.1.12" -"@overflow/rpc-js@0.0.5": - version "0.0.5" - resolved "https://nexus.loafle.net/repository/npm-all/@overflow/rpc-js/-/rpc-js-0.0.5.tgz#9b406d90a7b034cbd679985c1f7a117d17a8983e" +"@overflow/rpc-js@0.0.7": + version "0.0.7" + resolved "https://nexus.loafle.net/repository/npm-all/@overflow/rpc-js/-/rpc-js-0.0.7.tgz#3f800359653db92324976fa92fcae35b70053ccb" + dependencies: + "@overflow/core-js" "^0.0.7" "@schematics/angular@0.7.3": version "0.7.3"