/// <summary> /// 接收消息 /// </summary> /// <param name="pack"></param> public void ReceiveMessage(DataPackage pack) { if (pack.requestType == RequestType.account_login) { if (pack.status == 1) { // 用Loom的方法在Unity主线程中调用 Loom.QueueOnMainThread((param) => { //AsyncOperation async = SceneManager.LoadSceneAsync("lobby"); //async.allowSceneActivation = false; ReceiveManage.GetInstance().RemoveIistListeners(this); UI_LobbyManager.GetInitializeData(pack); SceneManager.LoadScene("lobby"); }, null); } else { // 用Loom的方法在Unity主线程中调用 Loom.QueueOnMainThread((param) => { hintText.text = "登录失败,密码错误或账号已存在"; Invoke("ClearText", 2f); }, null); } } }
private void DoBatchDelete() { IList <object> idList = RequestData.GetList <object>("IdList"); if (idList != null && idList.Count > 0) { ReceiveManage.DoBatchDelete(idList.ToArray()); } }
/// <summary> /// 访问实例 /// </summary> /// <returns></returns> public static ReceiveManage GetInstance() { if (receive == null) { receive = new ReceiveManage(); } return(receive); }
private void OnDestroy() { print("关闭程序"); //关闭套接字连接 ConnectInfo.GetInstance().CloseSocket(); //清理监听器 ReceiveManage.GetInstance().Close(); //退出时保存聊天记录 ChatHistoryManager.GetInstance().ExitAndSave(); }
// Start is called before the first frame update void Start() { ReceiveManage.GetInstance().AddListeners(this); loginBut.onClick.AddListener(LoginBut); enrollBut.onClick.AddListener(EnrollBut); confirmBut.onClick.AddListener(ConfirmBut); cancelBut.onClick.AddListener(CancelBut); securityCodePanel.SetActive(false); }
// Start is called before the first frame update void Start() { ReceiveManage.GetInstance().AddListeners(this); UserInstance = new UserInfo(); loginBut.onClick.AddListener(LoginBut); enrollBut.onClick.AddListener(EnrollBut); //实例化 Loom.Initialize(); enrollPanel.SetActive(false); }
/// <summary> /// 接收回调 /// </summary> private void ReceiveSorket() { //在这个线程中接受服务器返回的数据 while (true) { if (!socket.Connected) { //与服务器断开连接跳出循环 Debug.LogError("与服务器断开连接"); if (socket != null) { socket.Close(); } break; } try { //接受数据保存至bytes当中 byte[] bytes = new byte[4096]; int i = socket.Receive(bytes, 0, bytes.Length, SocketFlags.None); if (i <= 0) { if (socket != null) { socket.Close(); } break; } //接收消息管理器 ReceiveManage.GetInstance().ReceiveByte(bytes); } catch (Exception e) { Debug.LogError("客户端套接字错误." + e); if (socket != null) { socket.Close(); } break; } } }
string type = String.Empty; // 对象类型 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); type = RequestData.Get <string>("type"); ReceiveManage ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <ReceiveManage>(); ent.DoUpdate(); ent.LastModifyTime = DateTime.Now; this.SetMessage("修改成功!"); break; case RequestActionEnum.Insert: case RequestActionEnum.Create: ent = this.GetPostedData <ReceiveManage>(); ent.LastModifyTime = DateTime.Now; ent.DoCreate(); this.SetMessage("新建成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <ReceiveManage>(); ent.DoDelete(); this.SetMessage("删除成功!"); return; } if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { ent = ReceiveManage.Find(id); } this.SetFormData(ent); } }
protected void Page_Load(object sender, EventArgs e) { ReceiveManage ent = null; switch (this.RequestAction) { case RequestActionEnum.Delete: ent = this.GetTargetData <ReceiveManage>(); ent.DoDelete(); this.SetMessage("删除成功!"); break; default: if (RequestActionString == "batchdelete") { DoBatchDelete(); } else { DoSelect(); } break; } }
// Start is called before the first frame update void Start() { playGameBut.onClick.AddListener(PlayGameBut); ReceiveManage.GetInstance().AddListeners(this); }
// Start is called before the first frame update void Start() { findBut.onClick.AddListener(FindBut); ReceiveManage.GetInstance().AddListeners(this); }
// Start is called before the first frame update void Start() { ReceiveManage.GetInstance().AddListeners(this); }