This commit is contained in:
insanity 2017-09-27 16:59:20 +09:00
parent 7b7465decf
commit 440c9622a4
3 changed files with 20 additions and 5 deletions

View File

@ -70,7 +70,7 @@ export interface RPCConfig {
url: string;
}
const rpcConfig: RPCConfig = {
url: 'ws://192.168.1.50:19090/web',
url: 'ws://192.168.1.209:19090/web',
};
// REST Server Configuration

View File

@ -1,12 +1,17 @@
export class ServiceInvoker {
private configMap: Map<string, string>;
private configMap: Map<string, Object>;
public constructor() {
this.configMap = new Map();
}
public invoke(className: string, methodName: string): void {
return;
public invoke(className: string, methodName: string, params?: any): void {
let classObj: Object = this.configMap[className];
if (!classObj.hasOwnProperty(methodName)) {
console.log('Error: Cannot find the method. [' + methodName + ']');
return;
}
classObj[methodName]();
}
}

View File

@ -4,6 +4,7 @@ import {
Request,
Response,
} from './protocol';
import { ServiceInvoker } from '../invoke/ServiceInvoker';
export type OnDisconnectFunc = () => void;
export type OnResponseFunc = (response: any) => void;
@ -186,7 +187,16 @@ export default class WebSocketRPC {
}
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 {