示例#1
0
        private void switchRoomBtn_Click(object sender, EventArgs e)
        {
            string roomId    = this.roomIdTextBox.Text;
            string strRoomId = this.strRoomIdTextBox.Text;

            if (String.IsNullOrEmpty(roomId) && String.IsNullOrEmpty(strRoomId))
            {
                MessageForm msgBox = new MessageForm();
                msgBox.setText("切换房间号不能为空!");
                msgBox.setCancelBtn(false);
                msgBox.ShowDialog();
                return;
            }
            uint room = 0;

            if (!String.IsNullOrEmpty(roomId) && !uint.TryParse(roomId, out room))
            {
                ShowMessage(String.Format("目前支持的最大房间号为{0}", uint.MaxValue));
                return;
            }

            DataManager.GetInstance().roomId    = room;
            DataManager.GetInstance().strRoomId = strRoomId;
            string userSig = GenerateTestUserSig.GetInstance().GenTestUserSig(DataManager.GetInstance().userId);

            TRTCSwitchRoomConfig config = new TRTCSwitchRoomConfig();

            config.roomId    = room;
            config.strRoomId = strRoomId;
            config.userSig   = userSig;
            mTRTCCloud.switchRoom(ref config);
        }
示例#2
0
 public static GenerateTestUserSig GetInstance()
 {
     if (mInstance == null)
     {
         mInstance = new GenerateTestUserSig();
     }
     return(mInstance);
 }
示例#3
0
        private void OnJoinRoomBtnClick(object sender, EventArgs e)
        {
            if (GenerateTestUserSig.SDKAPPID == 0)
            {
                ShowMessage("Error: 请先在 GenerateTestUserSig 填写 sdkappid 信息");
                return;
            }

            SetTestEnv();
            SetPureAudioStyle();

            string userId = this.userTextBox.Text;
            string roomId = this.roomTextBox.Text;

            if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(roomId))
            {
                ShowMessage("房间号或用户号不能为空!");
                return;
            }

            uint room = 0;

            if (!uint.TryParse(roomId, out room))
            {
                ShowMessage(String.Format("目前支持的最大房间号为{0}", uint.MaxValue));
                return;
            }

            DataManager.GetInstance().userId = userId;
            DataManager.GetInstance().roomId = room;

            // 从本地计算获取 userId 对应的 userSig
            // 注意!本地计算是适合在本地环境下调试使用,正确的做法是将 UserSig 的计算代码和加密密钥放在您的业务服务器上,
            // 然后由 App 按需向您的服务器获取实时算出的 UserSig。
            // 由于破解服务器的成本要高于破解客户端 App,所以服务器计算的方案能够更好地保护您的加密密钥。
            string userSig = GenerateTestUserSig.GetInstance().GenTestUserSig(userId);

            if (string.IsNullOrEmpty(userSig))
            {
                ShowMessage("userSig 获取失败,请检查是否填写账号信息!");
                return;
            }

            this.Hide();
            TRTCMainForm mainForm = new TRTCMainForm(this);

            mainForm.Show();
            mainForm.EnterRoom();
        }
示例#4
0
        private void OnJoinRoomBtnClick(object sender, EventArgs e)
        {
            SetTestEnv();

            string userId = this.userTextBox.Text;
            string roomId = this.roomTextBox.Text;

            if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(roomId))
            {
                ShowMessage("房间号或用户号不能为空!");
                return;
            }
            int room = int.Parse(roomId);
            // 从本地计算获取 userId 对应的 userSig
            string userSig = GenerateTestUserSig.GetInstance().GenTestUserSig(userId);

            if (string.IsNullOrEmpty(userSig))
            {
                ShowMessage("userSig 获取失败,请检查是否填写账号信息!");
                return;
            }

            TRTCParams trtcParams = new TRTCParams();

            trtcParams.sdkAppId      = GenerateTestUserSig.SDKAPPID;
            trtcParams.roomId        = (uint)room;
            trtcParams.userId        = userId;
            trtcParams.userSig       = userSig;
            trtcParams.privateMapKey = "";
            trtcParams.businessInfo  = "";
            trtcParams.role          = TRTCRoleType.TRTCRoleAnchor;

            this.Hide();
            TRTCMainForm mainForm = new TRTCMainForm(this);

            mainForm.Show();
            SaveUserInfo();
            mainForm.SetTestEnv(mTestEnv);
            mainForm.EnterRoom(trtcParams);
        }