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); } }
private void PreloadResponse(string responseInfoStr) { GPlaySDK.LogFormat("GPlaySDKProxy.PreloadResponse", "responseInfoStr: {0}", responseInfoStr); PreloadResponseInfo responseInfo = ParsePreloadResponseInfo(responseInfoStr); if (responseInfo != null) { GPlaySDK.PreloadResponse(responseInfo); } }
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); }
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); }
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); } }
public int AddCallback(ActionCallback callback) { GPlaySDK.LogErrorFormat("ActionCallbackManager.AddCallback", "callbackID: {0}", callbackID); actionCallbacks[callbackID] = callback; return(callbackID++); }