Beispiel #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);
            }
        }
Beispiel #2
0
        protected void AsyncInvokePlatform(CallPlatformMethod invokeMethod, CallUnityMethod callbackMethod, Action <BridgeResponse> method, params JsonData[] args)
        {
            var request     = BridgeRequest.Create(invokeMethod.ToString(), callbackMethod.ToString(), args);
            var requestJson = request.ToJson();

            try
            {
                DebugUtility.Log(LoggerTags.Module, "异步调用 -> arg:{0};", requestJson);
                PushListener(request.callbackMethod, method);
                InvokePlatform(requestJson);
            }
            catch (Exception ex)
            {
                DebugUtility.LogError(LoggerTags.Module, "异步调用 -> arg:{0}; 异常 -> Exception:{1}", requestJson, ex);
            }
        }