/// <summary> /// 连接服务器回调 /// </summary> /// <param name="obj"></param> private void OnConnectedCallBack(bool isSuccess) { UIViewManager.Instance.CloseWait(); if (isSuccess) { NetWorkSocket.Instance.GetSocket(SocketHandle).OnDisConnect = OnDisConnectCallBack; //断开连接事件 NetWorkSocket.Instance.GetSocket(SocketHandle).OnReconnect = OnReconnectCallBack; //重新连接事件 m_CurrentGameCtrl = GetGameCtrl(CurrentGameId); if (m_CurrentGameCtrl == null) { throw new NotSupportedException("没有此Id:" + CurrentGameId.ToString()); } if (m_CurrentType == EnterRoomType.Create) { List <int> ids = new List <int>(); List <cfg_settingEntity> lst = cfg_settingDBModel.Instance.GetOptionsByGameId(CurrentGameId); for (int i = 0; i < lst.Count; ++i) { if (lst[i].status == 1 && lst[i].init == 1) { Debug.Log(lst[i].id); ids.Add(lst[i].id); } } m_CurrentGameCtrl.CreateRoom(m_nCurrentGroupId, ids); } else if (m_CurrentType == EnterRoomType.Join) { m_CurrentGameCtrl.JoinRoom(m_nCurrentJoinRoomId); } else { m_CurrentGameCtrl.RebuildRoom(); } } else { if (m_CurrentType == EnterRoomType.Renter) { UIViewManager.Instance.ShowMessage("错误提示", "网络连接失败,请重新尝试", MessageViewType.Ok, RebuildRoom, null, 20f, AutoClickType.Ok); } else { UIViewManager.Instance.ShowMessage("错误提示", "网络连接失败", MessageViewType.Ok, ExitGame); } } }
/// <summary> /// 重新连接回调 /// </summary> private void OnReconnectCallBack() { m_CurrentGameCtrl.RebuildRoom(); }