void JoinRoom() { var param = new JoinRoomPara { PlayerInfo = new PlayerInfoPara { Name = Global.OpenId, CustomPlayerStatus = 0, CustomProfile = "TODO", }, }; Global.Room.InitRoom(new RoomInfo() { Id = waitStartInfo.roomName, }); Global.Room.JoinRoom(param, (e) => { Debug.Log(e); if (e.Code == ErrCode.EcOk) { AddAction(() => this.StartGame()); } }); }
/// <summary> /// 加入团队房间 /// </summary> /// <param name="para"></param> /// <param name="callback"></param> public void JoinRoom(JoinRoomPara para, Action <ResponseEvent> callback) { Sdk.JoinRoom(para, this.RoomInfo.Id, (eve) => { if (eve.Data != null) { var rsp = new JoinRoomRsp(); rsp.MergeFrom((ByteString)eve.Data); eve.Data = rsp.RoomInfo?.ToByteString(); this.RoomUtil.SaveRoomInfo(eve); eve.Data = rsp; } callback?.Invoke(eve); }); }
public void Btn_Join() { if (TelentDrawController.instance && TelentDrawController.instance.ChatOk) { PlayerInfoPara playerInfoPara = new PlayerInfoPara { Name = usrJoinName.text.Trim(), CustomProfile = "customStr", CustomPlayerStatus = 1, }; // id="k8Ub1rle" JoinRoomPara joinRoomPara = new JoinRoomPara { PlayerInfo = playerInfoPara }; GetRoomListPara getRoomListPara = new GetRoomListPara { PageNo = 1, PageSize = 10, }; string roomId = roomJoinId.text.Trim(); TelentDrawController.instance.JoinRoomId = roomId; TelentDrawController.instance.PlayerInfoPara = playerInfoPara; TelentDrawController.instance.JoinPara = joinRoomPara; TelentDrawController.instance.paintJoinState = PaintJoinState.Joined; TelentDrawController.instance.CurrentRoomName = roomCreateName.text.Trim(); // 不要使用 room.getRoomList // 直接使用 Room 对象 Room.GetRoomList(getRoomListPara, (ResponseEvent eve) => { if (eve.Code == 0) { GetRoomListRsp rsp = (GetRoomListRsp)eve.Data; Debug.Log(rsp.Total); RepeatedField <RoomInfo> infos = rsp.RoomList; for (int i = 0; i < infos.Count; i++) { if (roomId == infos[i].Id) { if ((int)infos[i].MaxPlayers == infos[i].PlayerList.Count) { if (ToastManager.instance) { ToastManager.instance.AddToast(ToastType.Error, "人员已满"); } break; } findRoom = true; // Debug.Log(infos[i].Id); break; } } if (!findRoom) { if (ToastManager.instance) { ToastManager.instance.AddToast(ToastType.Error, "未找到房间号"); } } } else { Debug.Log(eve); } }); } }