示例#1
0
        private void ActionCallback(string callbackInfoStr)
        {
            GPlaySDK.LogFormat("GPlaySDKProxy.ActionCallback", "callbackInfoStr: {0}", callbackInfoStr);
            var callbackInfo = ParseCallbackResult(callbackInfoStr);

            if (callbackInfo != null)
            {
                ActionCallbackManager.Instance.Invoke(callbackInfo.callbackID, callbackInfo.resultCode, callbackInfo.resultJson);
            }
        }
示例#2
0
        private void PreloadResponse(string responseInfoStr)
        {
            GPlaySDK.LogFormat("GPlaySDKProxy.PreloadResponse", "responseInfoStr: {0}", responseInfoStr);
            PreloadResponseInfo responseInfo = ParsePreloadResponseInfo(responseInfoStr);

            if (responseInfo != null)
            {
                GPlaySDK.PreloadResponse(responseInfo);
            }
        }
示例#3
0
        private ActionCallbackInfo ParseCallbackResult(string callbackInfoStr)
        {
            GPlaySDK.LogFormat("GPlaySDKProxy.ParseCallbackResult", "callbackInfoStr: {0}", callbackInfoStr);
            ActionCallbackInfo actionCallbackInfo = new ActionCallbackInfo();

            Regex regex = new Regex(@"\{""callbackID"":(?<callbackID>[+\-\d]+), ""resultCode"":(?<resultCode>[+\-\d]+), ""resultJson"":(?<resultJson>[\s\S]*)\}");
            Match match = regex.Match(callbackInfoStr);

            actionCallbackInfo.callbackID = int.Parse(match.Groups["callbackID"].Value);
            actionCallbackInfo.resultCode = (EActionResultCode)int.Parse(match.Groups["resultCode"].Value);
            actionCallbackInfo.resultJson = match.Groups["resultJson"].Value;

            return(actionCallbackInfo);
        }
示例#4
0
        private PreloadResponseInfo ParsePreloadResponseInfo(string responseInfoStr)
        {
            GPlaySDK.LogFormat("GPlaySDKProxy.ParsePreloadResponseInfo", "responseInfoStr: {0}", responseInfoStr);
            Regex regex = new Regex(@"\{""resultCode"":(?<resultCode>[+\-\d]+), ""errorCode"":(?<errorCode>[+\-\d]+), ""groupName"":(?<groupName>[\s\S]*), ""percent"":(?<percent>[+\-\.\d]+), ""downloadSpeed"":(?<downloadSpeed>[+\-\.\d]+)\}");

            Match match        = regex.Match(responseInfoStr);
            var   responseInfo = new PreloadResponseInfo();

            responseInfo.resultCode    = (EActionResultCode)int.Parse(match.Groups["resultCode"].Value);
            responseInfo.errorCode     = (EActionResultCode)int.Parse(match.Groups["errorCode"].Value);
            responseInfo.groupName     = match.Groups["groupName"].Value;
            responseInfo.percent       = float.Parse(match.Groups["percent"].Value);
            responseInfo.downloadSpeed = float.Parse(match.Groups["downloadSpeed"].Value);

            return(responseInfo);
        }
示例#5
0
        public void Invoke(int callbackID, EActionResultCode resultCode, string msg)
        {
            GPlaySDK.LogFormat("ActionCallbackManager.Invoke", "callbackID: {0}  result:{1}  msg:{2}", callbackID, resultCode, msg);
            if (actionCallbacks.ContainsKey(callbackID))
            {
                if (actionCallbacks[callbackID] != null)
                {
                    actionCallbacks[callbackID].Invoke(resultCode, msg);
                }
                else
                {
                    GPlaySDK.LogErrorFormat("ActionCallbackManager.Invoke", "callbackID callback({0}) is null", callbackID);
                }

                actionCallbacks.Remove(callbackID);
            }
            else
            {
                GPlaySDK.LogErrorFormat("ActionCallbackManager.Invoke", "callbackID({0}) not exists", callbackID);
            }
        }
示例#6
0
 public int AddCallback(ActionCallback callback)
 {
     GPlaySDK.LogErrorFormat("ActionCallbackManager.AddCallback", "callbackID: {0}", callbackID);
     actionCallbacks[callbackID] = callback;
     return(callbackID++);
 }