Esempio n. 1
0
        protected BridgeResponse SyncInvokePlatform(CallPlatformMethod invokeMethod, params JsonData[] args)
        {
            var request     = BridgeRequest.Create(invokeMethod.ToString(), args);
            var requestJson = request.ToJson();

            BridgeResponse response = null;

            try
            {
                var result = InvokePlatform(requestJson);
                response = BridgeResponse.Deserialize(result);

                if (response == null)
                {
                    DebugUtility.LogError(LoggerTags.Module, "同步调用 -> arg:{0}; 解析错误 -> result:{1}", requestJson, result);
                    response = BridgeResponse.CreateErrorResponse(request.id, BridgeCode.ReturnTypeError);
                    return(response);
                }
                else
                {
                    DebugUtility.Log(LoggerTags.Module, "同步调用 -> arg:{0}; 返回 -> result:{1}", requestJson, result);
                    return(response);
                }
            }
            catch (Exception ex)
            {
                DebugUtility.LogError(LoggerTags.Module, "同步调用 -> arg:{0}; 异常 -> Exception:{1}", requestJson, ex);
                response = BridgeResponse.CreateErrorResponse(request.id, BridgeCode.InvokeParamError);
                return(response);
            }
        }
Esempio n. 2
0
        public void onCallback(string result)
        {
            var response = BridgeResponse.Deserialize(result);

            if (response == null)
            {
                DebugUtility.LogError(LoggerTags.Module, "平台回调 -> 异常result:{0}", result);
                return;
            }
            DebugUtility.Log(LoggerTags.Module, "平台回调 -> result:{0}", result);
            //提取动态事件
            var method = caller.PullListener(response.callbackMethod, response.IsComplete);

            if (method != null)
            {
                method.SafeInvoke(response);
            }
            else
            {
                DebugUtility.LogError(LoggerTags.Module, "平台回调 -> 方法未监听!key:{0}", response.callbackMethod);
            }
        }