//函数定义 private IEnumerator Request(WWW data) { yield return(data); //在当前帧停止执行当前代码转去执行调用他的主线程 IsBusy = false; if (!string.IsNullOrEmpty(data.error)) { if (m_postCallBack != null) { CallBackArgs args = new CallBackArgs { HasError = true, Value = null, ErrorMsg = data.error }; m_postCallBack(args); } } else { if (m_postCallBack != null) { CallBackArgs args = new CallBackArgs { HasError = false, ErrorMsg = null, Value = data.text, }; m_postCallBack(args); } } }
private void OnRegCallBack(CallBackArgs obj) { if (obj.IsError) { Debug.Log("发送消息失败"); } else { RetValue ret = LitJson.JsonMapper.ToObject <RetValue>(obj.Json); if (ret.IsError) { Debug.Log(ret.ErrorMsg); } else { RetAccountEntity accountEntity = LitJson.JsonMapper.ToObject <RetAccountEntity>(ret.RetData.ToString()); Global.Instance.AccountEntity = accountEntity; SetLastGameServer(accountEntity); if (isAutoLogOn) { } else { string userName = regView.UserNameInput.text; string pwd = regView.PwdInput.text; PlayerPrefs.SetInt(ConstDefine.PlayerPrefs_AccountID_Key, accountEntity.Id); PlayerPrefs.SetString(ConstDefine.PlayerPrefs_UserName_Key, userName); PlayerPrefs.SetString(ConstDefine.PlayerPrefs_Pwd_Key, pwd); } regView.CloseAndOpenNextView(UIViewType.GameServerEnter); Debug.Log("注册成功" + ret.RetData); } } }
void Contacts_CallBack(object sender, CallBackArgs e) { Contacts.Clear(); mre = e.Mre; foreach (var item in e.Phones) { Contacts.Add(item); } }
/// <summary> /// 更新最后登录的服务器回调 /// </summary> /// <param name="obj"></param> private void UpdateLastServerCallBack(CallBackArgs obj) { if (!obj.IsError) { } else { Debug.Log("Update Over"); } }
private void GetServerTimeCallBack(CallBackArgs obj) { if (obj.IsError) { Debug.Log(obj.Error); } else { m_ServerTime = obj.Json.ToLong(); Debug.Log(m_ServerTime); } }
private void GetCallBack(CallBackArgs obj) { if (obj.IsError) { Debug.Log(obj.Error); } else { AccountEntity entity = JsonMapper.ToObject <AccountEntity>(obj.jsonData); Debug.Log(entity.UserName); } }
private void PostCallBack(CallBackArgs obj) { if (obj.IsError) { Debug.Log(obj.Error); } else { RetValue ret = JsonMapper.ToObject <RetValue>(obj.jsonData); if (ret.isError) { Debug.LogError(ret.Error); } else { Debug.Log("新注册的用户编号为:" + ret.JsonData); } } }
/// <summary> /// 获取服务器列表回调 /// </summary> /// <param name="obj"></param> private void GetGameServerListCallBack(CallBackArgs obj) { if (obj.IsError) { ShowMsg("Error", "Error"); } else { List <RetGameserverEntity> list = LitJson.JsonMapper.ToObject <List <RetGameserverEntity> >(obj.Json); pageTpGameServerList[currentIndex] = list; if (list == null) { ShowMsg("Error", "Error"); } else { m_GameServerSelectView.SetGameServerGrid(list); } } }
/// <summary> /// 获取服务器页签列表回调 /// </summary> /// <param name="obj"></param> private void GetGanmeServerPageListCallBack(CallBackArgs obj) { if (obj.IsError) { ShowMsg("Error", "Error"); } else { List <RetGameServerPageEntity> list = LitJson.JsonMapper.ToObject <List <RetGameServerPageEntity> >(obj.Json); if (list == null) { ShowMsg("Error", "Error"); } else { m_GameServerSelectView.SetGameServerPageGrid(list); GetGameServerList(0); } } }
//函数定义 private IEnumerator Get(WWW data) { yield return(data); //在当前帧停止执行当前代码转去执行调用他的主线程 IsBusy = false; if (!string.IsNullOrEmpty(data.error)) { Debug.Log(data.error); } else { if (data.text == "null") { m_callbackArgs = new CallBackArgs { ErrorMsg = "没有得到id对应用户信息", HasError = true, }; if (m_getCallBack != null) { m_getCallBack(m_callbackArgs); } } else if (m_getCallBack != null) { m_callbackArgs = new CallBackArgs { ErrorMsg = "", HasError = false, Value = data.text }; m_getCallBack(m_callbackArgs); } } }
public override void OnSingletonInit() { base.OnSingletonInit(); m_CallBackArgs = new CallBackArgs(); }
/// <summary> /// 请求服务器 /// </summary> /// <param name="www"></param> /// <returns></returns> private IEnumerator Request(WWW www, HttpSendPackage package) { LogSystem.Log(www.url); CallBackArgs args = new CallBackArgs(); float timeOut = Time.time; float progress = www.progress; while (www != null && !www.isDone) { if (progress < www.progress) { timeOut = Time.time; progress = www.progress; } if (Time.time - timeOut > TIME_OUT) { www.Dispose(); AppDebug.LogWarning("HTTP超时"); ++package.timeOutCount; if (package.timeOutCount >= MAX_TIME_OUT_COUNT) { if (package.callBack != null) { args.HasError = true; args.ErrorMsg = "请求超时"; package.callBack(args); } } else { if (package.isPost) { PostUrl(package); } else { GetUrl(package); } } yield break; } yield return(null); } yield return(www); if (www.error == null) { AppDebug.Log(www.text); if (www.text.Equals("null", StringComparison.OrdinalIgnoreCase)) { if (package.callBack != null) { args.HasError = true; args.ErrorMsg = "未请求到数据"; package.callBack(args); } } else { if (package.callBack != null) { try { args.HasError = false; LitJson.JsonData jsonData = LitJson.JsonMapper.ToObject(www.text); args.Value = new Ret() { code = jsonData["code"].ToString().ToInt(), data = jsonData["data"], msg = jsonData["msg"].ToString() }; } catch { AppDebug.Log(www.text); args.HasError = true; args.ErrorMsg = "数据异常"; } finally { package.callBack(args); if (args.Value != null && (args.Value.code == -91017 || args.Value.code == -91018)) { if (OnTokenError != null) { OnTokenError(args); } } } } } } else { if (package.callBack != null) { args.HasError = true; args.ErrorMsg = "网络异常"; package.callBack(args); } AppDebug.Log("连接失败" + www.error); } www.Dispose(); }
protected override void OnStart() { base.OnStart(); m_CallBackArgs = new CallBackArgs(); }
protected override void OnStart() { base.OnStart(); //只在一个地方实例化,节省内存 m_CallBackArgs = new CallBackArgs(); }
private void Start() { m_CallBackArgs = new CallBackArgs(); }
public int DefaultCallBackHandler(IntPtr hwnd, TASKDIALOG_NOTIFICATIONS uNotification, IntPtr wParam, IntPtr lParam, IntPtr dwRefData) { CallBackArgs args = new CallBackArgs(hwnd, uNotification, wParam, lParam, dwRefData); if (OnCallBack != null) { OnCallBack(this, args); if (args.SkipDefaultHandler) { return(args.ReturnValue); } } switch (uNotification) { case TASKDIALOG_NOTIFICATIONS.TDN_BUTTON_CLICKED: if (OnButtonClicked != null) { ButtonClickedArgs barg = new ButtonClickedArgs(args.UserData, (int)wParam); OnButtonClicked(this, barg); return(barg.PreventClosing ? 1 : 0); } else { return(0); } case TASKDIALOG_NOTIFICATIONS.TDN_CREATED: UpdateControlsOnCreate(); if (OnCreate != null) { OnCreate(this, args.UserData); } return(0); case TASKDIALOG_NOTIFICATIONS.TDN_DESTROYED: this.hWnd = IntPtr.Zero; if (OnDestroy != null) { OnDestroy(this, args.UserData); } return(0); case TASKDIALOG_NOTIFICATIONS.TDN_DIALOG_CONSTRUCTED: this.hWnd = hwnd; if (OnConstructed != null) { OnConstructed(this, args.UserData); } return(0); case TASKDIALOG_NOTIFICATIONS.TDN_EXPANDO_BUTTON_CLICKED: if (OnExpandButtonClicked != null) { OnExpandButtonClicked(this, args.UserData, wParam != IntPtr.Zero); } return(0); case TASKDIALOG_NOTIFICATIONS.TDN_HYPERLINK_CLICKED: if (OnHyperLinkClicked != null) { OnHyperLinkClicked(this, args.UserData, Marshal.PtrToStringUni(lParam)); } return(0); case TASKDIALOG_NOTIFICATIONS.TDN_NAVIGATED: if (OnNavigated != null) { OnNavigated(this, args.UserData); } return(0); case TASKDIALOG_NOTIFICATIONS.TDN_RADIO_BUTTON_CLICKED: SelectedRadioButton = (int)wParam; if (OnRadioButtonSelected != null) { OnRadioButtonSelected(this, args.UserData, SelectedRadioButton); } return(0); case TASKDIALOG_NOTIFICATIONS.TDN_TIMER: if (OnTimerTick != null) { TimerTickArgs tArg = new TimerTickArgs(args.UserData, (int)wParam); OnTimerTick(this, tArg); return(tArg.Reset ? 1 : 0); } else { return(0); } case TASKDIALOG_NOTIFICATIONS.TDN_VERIFICATION_CLICKED: if (OnCheckBoxClicked != null) { OnCheckBoxClicked(this, args.UserData, wParam != IntPtr.Zero); } return(0); default: return(0); } }