ing
This commit is contained in:
parent
4dde0f3aca
commit
69535f452d
|
@ -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<RPCSubscriberDecoratorAttribute>(RPCSubscriberDecorator);
|
||||
// export const RPCSubscriber = DecoratorHelper.create<RPCSubscriberDecoratorAttribute>(RPCSubscriberDecorator);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -67,26 +67,6 @@ export class HomePageComponent implements OnInit {
|
|||
};
|
||||
|
||||
this.probeService.send('DiscoveryService.DiscoverHost', requesterID, zone, discoverHost);
|
||||
|
||||
// this.probeService.call<Interface>('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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
14
yarn.lock
14
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"
|
||||
|
|
Loading…
Reference in New Issue
Block a user