示例#1
0
        public void RtsTest()
        {
            VideoChatForm vchatForm = VideoChatForm.GetInstance();
            RtsForm       rtsForm   = RtsForm.GetInstance();


            //当前不存在白板会话和音视频会话,才能开启新的会话
            if (rtsForm.RtsState == RtsFormState.kRtsInit && vchatForm.VchatInfo.state == VChatState.kVChatUnknow)
            {
                rtsForm.Show();
                rtsForm.SetRtsInfo("", _peerId, (NIM.NIMRts.NIMRtsChannelType.kNIMRtsChannelTypeTcp | NIM.NIMRts.NIMRtsChannelType.kNIMRtsChannelTypeVchat));
                rtsForm.RtsState = RtsFormState.kRtsInvite;
            }
            else
            {
                if (rtsForm.RtsState != RtsFormState.kRtsInit)
                {
                    rtsForm.Activate();
                }
                if (vchatForm.VchatInfo.state != VChatState.kVChatUnknow)
                {
                    vchatForm.Activate();
                }
            }
            //rtsForm.SetRtsInfo
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            VideoChatForm vchatForm = VideoChatForm.GetInstance();
            RtsForm       rtsForm   = RtsForm.GetInstance();

            //当前不存在白板会话和音视频会话,才能开启新的会话
            if (rtsForm.RtsState == RtsFormState.kRtsInit && vchatForm.VchatInfo.state == VChatState.kVChatUnknow)
            {
                VideoChatInfo vchat_info = vchatForm.VchatInfo;
                vchat_info.state     = VChatState.kVChatInvite;
                vchat_info.uid       = _peerId;
                vchat_info.chat_mode = NIMVideoChatMode.kNIMVideoChatModeVideo;
                vchatForm.VchatInfo  = vchat_info;
                vchatForm.Show();
            }
            else
            {
                if (rtsForm.RtsState != RtsFormState.kRtsInit)
                {
                    rtsForm.Activate();
                }
                else if (vchatForm.VchatInfo.state != VChatState.kVChatUnknow)
                {
                    vchatForm.Activate();
                }
            }
        }
 private static void OnSessionInviteNotify(long channel_id, string uid, int mode, long time, string custom_info)
 {
     if (GetInstance().channel_id != 0 && channel_id != GetInstance().channel_id)
     {
         NIM.NIMVChatInfo info = new NIM.NIMVChatInfo();
         NIM.VChatAPI.CalleeAck(channel_id, false, info);
     }
     else
     {
         VideoChatForm vform      = VideoChatForm.GetInstance();
         RtsForm       rtsForm    = RtsForm.GetInstance();
         VideoChatInfo vchat_info = vform.VchatInfo;
         //当前不存在rts会话和音视频会话,才能开启新的会话
         if (rtsForm.RtsState == RtsFormState.kRtsInit && vchat_info.state == VChatState.kVChatUnknow)
         {
             vchat_info.channel_id = channel_id;
             vchat_info.uid        = uid;
             vchat_info.state      = VChatState.kVChatNotify;
             vchat_info.chat_mode  = (NIMVideoChatMode)mode;
             vform.VchatInfo       = vchat_info;
             Action a = () =>
             {
                 vform.Show();
             };
             _ownerMainForm.BeginInvoke(a);
         }
         else
         {
             NIM.NIMVChatInfo info = new NIM.NIMVChatInfo();
             NIM.VChatAPI.CalleeAck(channel_id, false, info);
         }
     }
 }
示例#4
0
 public static RtsForm GetInstance()
 {
     if (_rtsForm == null)
     {
         _rtsForm = new RtsForm();
     }
     return(_rtsForm);
 }
示例#5
0
 private void RtsForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     _sendDataTimer.Stop();
     NIM.RtsAPI.Hangup(_sessionId, (a, b) =>
     {
     });
     NIM.DeviceAPI.EndDevice(NIM.NIMDeviceType.kNIMDeviceTypeAudioIn);
     NIM.DeviceAPI.EndDevice(NIM.NIMDeviceType.kNIMDeviceTypeAudioOutChat);
     System.Threading.Thread.Sleep(2000);
     _rtsForm = null;
 }
示例#6
0
 void Response(int code, string sessionId, int channelType, bool accept)
 {
     if (accept && code == (int)NIM.ResponseCode.kNIMResSuccess)
     {
         InvokeOnForm(() =>
         {
             var form = new RtsForm(sessionId);
             form.Show();
         });
     }
     else if (code != (int)NIM.ResponseCode.kNIMResSuccess)
     {
         MessageBox.Show("建立白板会话失败:" + code.ToString());
     }
 }
示例#7
0
 void OnReceiveSessionRequest(string sessionId, int channelType, string uid, string custom)
 {
     InvokeOnForm(() =>
     {
         VideoChatForm vchatForm = VideoChatForm.GetInstance();
         RtsForm rtsForm         = RtsForm.GetInstance();
         //当前不存在白板会话和音视频会话,才能开启新的会话
         if (rtsForm.RtsState == RtsFormState.kRtsInit && vchatForm.VchatInfo.state == VChatState.kVChatUnknow)
         {
             rtsForm.Show();
             rtsForm.RtsState = RtsFormState.kRtsNotify;
             rtsForm.SetRtsInfo(sessionId, uid, (NIM.NIMRts.NIMRtsChannelType)channelType);
         }
         else
         {
             NIM.RtsAPI.Ack(sessionId, (NIM.NIMRts.NIMRtsChannelType)channelType, false, null, null);
         }
     });
 }
 public void RtsTest()
 {
     NIM.NIMRts.RtsStartInfo info = new NIM.NIMRts.RtsStartInfo();
     info.ApnsText   = "123";
     info.CustomInfo = "456";
     RtsAPI.SetAckNotifyCallback((a, b, c, d) =>
     {
         this.InvokeOnMainThread(() =>
         {
             if (!c)
             {
                 MessageBox.Show("对方拒绝");
             }
             else
             {
                 RtsForm f = new RtsForm(a);
                 f.Show();
             }
         });
     });
     RtsAPI.Start((NIM.NIMRts.NIMRtsChannelType.kNIMRtsChannelTypeTcp | NIM.NIMRts.NIMRtsChannelType.kNIMRtsChannelTypeVchat), _peerId, info,
                  (code, sessionId, channelType, uid) =>
     {
         this.InvokeOnMainThread(() =>
         {
             if (code == 200)
             {
                 MessageBox.Show("邀请已发送,等待对方加入");
             }
             else
             {
                 MessageBox.Show("邀请失败:" + ((NIM.ResponseCode)code).ToString());
             }
         });
     });
 }