ing
This commit is contained in:
parent
7b7465decf
commit
440c9622a4
|
@ -70,7 +70,7 @@ export interface RPCConfig {
|
||||||
url: string;
|
url: string;
|
||||||
}
|
}
|
||||||
const rpcConfig: RPCConfig = {
|
const rpcConfig: RPCConfig = {
|
||||||
url: 'ws://192.168.1.50:19090/web',
|
url: 'ws://192.168.1.209:19090/web',
|
||||||
};
|
};
|
||||||
|
|
||||||
// REST Server Configuration
|
// REST Server Configuration
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
export class ServiceInvoker {
|
export class ServiceInvoker {
|
||||||
|
|
||||||
private configMap: Map<string, string>;
|
private configMap: Map<string, Object>;
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
this.configMap = new Map();
|
this.configMap = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
public invoke(className: string, methodName: string): void {
|
public invoke(className: string, methodName: string, params?: any): void {
|
||||||
return;
|
let classObj: Object = this.configMap[className];
|
||||||
|
if (!classObj.hasOwnProperty(methodName)) {
|
||||||
|
console.log('Error: Cannot find the method. [' + methodName + ']');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
classObj[methodName]();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
Request,
|
Request,
|
||||||
Response,
|
Response,
|
||||||
} from './protocol';
|
} from './protocol';
|
||||||
|
import { ServiceInvoker } from '../invoke/ServiceInvoker';
|
||||||
|
|
||||||
export type OnDisconnectFunc = () => void;
|
export type OnDisconnectFunc = () => void;
|
||||||
export type OnResponseFunc = (response: any) => void;
|
export type OnResponseFunc = (response: any) => void;
|
||||||
|
@ -186,7 +187,16 @@ export default class WebSocketRPC {
|
||||||
|
|
||||||
}
|
}
|
||||||
private onNotificationHandler(notification: Notification): void {
|
private onNotificationHandler(notification: Notification): void {
|
||||||
// invoke
|
let methodArr = notification.Method.split('.');
|
||||||
|
if (methodArr.length !== 2) {
|
||||||
|
console.log('Cannot process notification. [' + notification.Method + ']');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let className = methodArr[0];
|
||||||
|
let methodName = methodArr[1];
|
||||||
|
|
||||||
|
let serviceInvoker: ServiceInvoker = new ServiceInvoker();
|
||||||
|
serviceInvoker.invoke(className, methodName, notification.Params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private fireOnDisconnect(): void {
|
private fireOnDisconnect(): void {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user