From 440c9622a4271e1751e8d1d60dac2f83a5899346 Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 27 Sep 2017 16:59:20 +0900 Subject: [PATCH] ing --- src/ts/@overflow/app/config/index.ts | 2 +- src/ts/@overflow/commons/invoke/ServiceInvoker.ts | 11 ++++++++--- src/ts/@overflow/commons/websocket/WebSocketRPC.ts | 12 +++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index dab8d26..4bdf67f 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -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 diff --git a/src/ts/@overflow/commons/invoke/ServiceInvoker.ts b/src/ts/@overflow/commons/invoke/ServiceInvoker.ts index fb2508e..b232c68 100644 --- a/src/ts/@overflow/commons/invoke/ServiceInvoker.ts +++ b/src/ts/@overflow/commons/invoke/ServiceInvoker.ts @@ -1,12 +1,17 @@ export class ServiceInvoker { - private configMap: Map; + private configMap: Map; 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](); } } diff --git a/src/ts/@overflow/commons/websocket/WebSocketRPC.ts b/src/ts/@overflow/commons/websocket/WebSocketRPC.ts index 3087d9f..3b21447 100644 --- a/src/ts/@overflow/commons/websocket/WebSocketRPC.ts +++ b/src/ts/@overflow/commons/websocket/WebSocketRPC.ts @@ -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 {