Ejemplo n.º 1
0
        //发送文件
        private void btnSendFile_Click(object sender, EventArgs e)
        {
            if (m_tempUserID == -1)
            {
                Print("没有目标用户");
            }
            else
            {
                OpenFileDialog dlgopenFile = new OpenFileDialog();
                dlgopenFile.Title = "选择需要发送的文件";
                DialogResult dr = dlgopenFile.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    if (File.Exists(dlgopenFile.FileName))
                    {
                        int taskId = -1;
                        if (AnyChatCoreSDK.TransFile(m_tempUserID, dlgopenFile.FileName, 1, 0, 0, ref taskId) == 0)
                        {
                            Print("文件" + dlgopenFile.FileName + "发送成功");
                        }
                    }
                }
                dlgopenFile.Dispose();
                dlgopenFile = null;
            }
        }
Ejemplo n.º 2
0
        // 2013-05-24: GreenRose Created
        private void InitAllSetting()
        {
            AnyChatCoreSDK.SetNotifyMessageCallBack(OnNotifyMessageCallback, 0);
            AnyChatCoreSDK.SetVideoDataCallBack(AnyChatCoreSDK.PixelFormat.BRAC_PIX_FMT_RGB24, OnVideoDataCallback, 0);

            // 2014-01-17: GreenRose
            AnyChatCoreSDK.SetRecordCallBack(OnRecordCallBack, 0);

            ulong dwFuncMode = AnyChatCoreSDK.BRAC_FUNC_VIDEO_CBDATA | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOPLAY | AnyChatCoreSDK.BRAC_FUNC_CHKDEPENDMODULE
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_VOLUMECALC | AnyChatCoreSDK.BRAC_FUNC_NET_SUPPORTUPNP | AnyChatCoreSDK.BRAC_FUNC_FIREWALL_OPEN
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOVOLUME | AnyChatCoreSDK.BRAC_FUNC_CONFIG_LOCALINI;

            AnyChatCoreSDK.InitSDK(IntPtr.Zero, dwFuncMode);
            //AnyChatCoreSDK.Connect("demo.anychat.cn", 8906);
            //AnyChatCoreSDK.Connect("98.126.164.98", 8906);
            //AnyChatCoreSDK.Connect("192.168.0.2", 8906);
            AnyChatCoreSDK.Connect(Login._ServerServiceUri, 8906);
            AnyChatCoreSDK.Login("1", "", 0);
            AnyChatCoreSDK.EnterRoom(1, "", 0);


            NotifyMessageHandler = new AnyChatCoreSDK.NotifyMessage_CallBack(NotifyMessageCallbackDelegate);
            VideoDataHandler     = new AnyChatCoreSDK.VideoData_CallBack(VideoDataCallbackDelegate);
            RecordHandler        = new AnyChatCoreSDK.RecordCallBack(RecordDataCallBackDelegate);
        }
Ejemplo n.º 3
0
        private void Window_Closed(object sender, EventArgs e)
        {
            try
            {
                //if (localWebCam != null)
                //{
                //    if (localWebCam.IsRunning)
                //        localWebCam.Stop();
                //}

                if (disapthcerTimer != null)
                {
                    disapthcerTimer.IsEnabled = false;
                }

                AnyChatCoreSDK.LeaveRoom(-1);
                AnyChatCoreSDK.Logout();
                AnyChatCoreSDK.Release();

                //if (_writer != null)
                //    _writer.Close();

                Main.videoCreat = null;
            }
            catch (Exception ex)
            {
                string strError = ex.ToString();
                ErrorCollection.GetInstance().SetErrorInfo(strError);
            }
        }
Ejemplo n.º 4
0
        public void StartProc()
        {
            string path = System.Windows.Forms.Application.StartupPath + "\\Record\\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            foreach (FileInfo file in directoryInfo.GetFiles())
            {
                file.Delete();
            }

            try
            {
                //_writer = new VideoFileWriter();

                //_strRecordFilePath = path + Login._UserInfo.Id + System.DateTime.Now.ToString("yyyyMMddHHmm") + ".avi";
                //_writer.Open(_strRecordFilePath, 640, 480, 25, VideoCodec.MPEG4);

                //StartVideCapture();

                _strFileName = System.DateTime.Now.ToString("yyyyMMddHHmm");
                AnyChatCoreSDK.StreamRecordCtrl(-1, true, 0, 0);
                AnyChatCoreSDK.SnapShot(-1, 0, 0);
            }
            catch (Exception ex)
            {
                string strError = ex.ToString();
                ErrorCollection.GetInstance().SetErrorInfo(strError);
            }
        }
Ejemplo n.º 5
0
 //取消呼叫
 private void CanCall()
 {
     //发送视频呼叫回复指令,dwErrcode=100101
     AnyChatCoreSDK.VideoCallControl(AnyChatCoreSDK.BRAC_VIDEOCALL_EVENT_REPLY, ConversationMode.TuserId, AC_ERROR_VIDEOCALL_CANCEL, 0, 0, "");
     ConversationMode = null;
     InitFaceAfterEndCall(Properties.Resources._20, "已经取消呼叫");
 }
Ejemplo n.º 6
0
        //操作双方音视频设备
        public void OpenCameraAndSpeak(int userId, bool isopen)
        {
            if (isopen)
            {
                //打开呼叫者音视频
                AnyChatCoreSDK.UserCameraControl(userId, true);
                AnyChatCoreSDK.UserSpeakControl(userId, true);
                if (userId == m_UserId)
                {
                    AnyChatCoreSDK.SetVideoPos(userId, pic_suserVideo.Handle, 0, 0, pic_suserVideo.Width, pic_suserVideo.Height);
                }
                else
                {
                    AnyChatCoreSDK.SetVideoPos(userId, pic_tuserVideo.Handle, 0, 0, pic_tuserVideo.Width, pic_tuserVideo.Height);
                }
            }
            else
            {
                AnyChatCoreSDK.UserCameraControl(userId, false);
                AnyChatCoreSDK.UserSpeakControl(userId, false);
            }

            //音量刷新
            timer_speak.Enabled = isopen;
        }
Ejemplo n.º 7
0
 private void cbb_fbl_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbb_fbl.SelectedIndex == 0)
     {
         int bUseAppParam = 0;
         //应用本地视频编码参数,使得前述修改即时生效(参数为int型:1 使用新参数,0 使用默认参数)
         AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_APPLYPARAM, ref bUseAppParam, sizeof(int));
     }
     else
     {
         int bitrate = 0;  //0表示质量模式
         //设置本地视频编码的码率
         AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_BITRATECTRL, ref bitrate, sizeof(int));
         int keyframe = 25;
         //设置本地视频编码的关键帧间隔
         AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_GOPCTRL, ref keyframe, sizeof(int));
         int framerate = 25;
         //设置本地视频编码的帧率
         AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_FPSCTRL, ref framerate, sizeof(int));
         int defaultParam = 3;
         // 设置本地视频编码的预设参数
         AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_PRESETCTRL, ref defaultParam, sizeof(int));
         int bUseAppParam = 1;
         //应用本地视频编码参数,使得前述修改即时生效(参数为int型:1 使用新参数,0 使用默认参数)
         AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_APPLYPARAM, ref bUseAppParam, sizeof(int));
     }
 }
Ejemplo n.º 8
0
        void InitChat()
        {
            string path = Application.StartupPath;

            SystemSetting.Text_OnReceive        = new TextReceivedHandler(Received_Text);               //文本回调涵数
            SystemSetting.TransBuffer_OnReceive = new TransBufferReceivedHandler(Received_TransBuffer); //透明通道传输回调
            SystemSetting.TransFile_OnReceive   = new TransFileReceivedHandler(Received_TransFile);     //文件传输回调
            AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_CORESDK_PATH, path, path.Length);



            SystemSetting.Init(this.Handle);

            ////设置视频分辨率
            //int m_Refw = AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_WIDTHCTRL, ref frmLogin.m_LocalVideoWidth, sizeof(int));
            //int m_Refh = AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_HEIGHTCTRL, ref frmLogin.m_LocalVideoHeight, sizeof(int));
            ////应用本地视频编码参数,使得前述修改即时生效(参数为int型:1 使用新参数,0 使用默认参数)
            //int m_AppLocal = 1;
            //AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_APPLYPARAM, ref m_AppLocal, sizeof(int));

            //StringBuilder m_ServerKey = new StringBuilder();
            //m_ServerKey.Append("d");
            //int retkey = AnyChatCoreSDK.SetServerAuthPass(m_ServerKey);
            int ret = AnyChatCoreSDK.Connect(frmLogin.m_VideoServerIP, frmLogin.m_VideoTcpPort);

            ret = AnyChatCoreSDK.Login(frmLogin.m_UserName, "", 0);
        }
Ejemplo n.º 9
0
        // 打开远程用户的音频、视频
        public void OpenRemoteUserVideo()
        {
            if (g_otherUserId != -1)
            {
                return;
            }
            // 获取当前房间用户列表
            int usercount = 0;

            AnyChatCoreSDK.GetOnlineUser(null, ref usercount);
            if (usercount > 0)
            {
                int[] useridarray = new int[usercount];
                AnyChatCoreSDK.GetOnlineUser(useridarray, ref usercount);
                for (int i = 0; i < usercount; i++)
                {
                    // 判断该用户的视频是否已打开
                    int usercamerastatus = 0;
                    if (AnyChatCoreSDK.QueryUserState(useridarray[i], AnyChatCoreSDK.BRAC_USERSTATE_CAMERA, ref usercamerastatus, sizeof(int)) != 0)
                    {
                        continue;
                    }
                    if (usercamerastatus == 2)
                    {
                        AnyChatCoreSDK.UserSpeakControl(useridarray[i], true);
                        AnyChatCoreSDK.UserCameraControl(useridarray[i], true);
                        g_otherUserId = useridarray[i];
                        break;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private void GetSetting()
        {
            int retCode   = 0;
            int streamIdx = Int32.Parse((comboBox_videoDeviceList.SelectedItem as ComboBoxItem).Value.ToString());
            //streamIdx = streamIdx + 1;


            int videoBitrate = 0;

            if (streamIdx == 100)
            {
                retCode = AnyChatCoreSDK.QueryUserState(-1, AnyChatCoreSDK.BRAC_USERSTATE_VIDEOBITRATE, ref videoBitrate, sizeof(int));
            }
            else
            {
                retCode = AnyChatCoreSDK.GetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_STREAMINFO_VIDEOBITRATE, ref videoBitrate, sizeof(int));
            }
            for (int idx = 0; idx < comboBox_VideoBitrate.Items.Count; idx++)
            {
                if ((videoBitrate >= Int32.Parse((comboBox_VideoBitrate.Items[idx] as ComboBoxItem).Value.ToString())) &&
                    (videoBitrate <= Int32.Parse((comboBox_VideoBitrate.Items[idx + 1] as ComboBoxItem).Value.ToString())))
                {
                    comboBox_VideoBitrate.SelectedIndex = idx;
                    break;
                }
            }

            //分辨率
            int videoWidth  = 0;
            int videoHeigth = 0;

            retCode = AnyChatCoreSDK.GetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_STREAMINFO_VIDEOWIDTH, ref videoWidth, sizeof(int));
            retCode = AnyChatCoreSDK.GetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_STREAMINFO_VIDEOHEIGHT, ref videoHeigth, sizeof(int));
            string resolution = videoWidth.ToString() + "x" + videoHeigth;

            lblVideoResolution.Text = "(当前分辨率:	"+ resolution + ")";
            for (int idx = 0; idx < comboBox_VideoResolution.Items.Count; idx++)
            {
                if (resolution == (comboBox_VideoResolution.Items[idx] as ComboBoxItem).Text.ToString())
                {
                    comboBox_VideoResolution.SelectedIndex = idx;
                    break;
                }
            }


            //帧率
            int videoFPS = 0;

            //videoFPS = Int32.Parse((comboBox_VideoFPS.SelectedItem as ComboBoxItem).Value.ToString());
            retCode = AnyChatCoreSDK.GetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_STREAMINFO_VIDEOFPS, ref videoFPS, sizeof(int));
            for (int idx = 0; idx < comboBox_VideoFPS.Items.Count; idx++)
            {
                if (videoFPS.ToString() == (comboBox_VideoFPS.Items[idx] as ComboBoxItem).Value.ToString())
                {
                    comboBox_VideoFPS.SelectedIndex = idx;
                    break;
                }
            }
        }
Ejemplo n.º 11
0
        private void CreateUserVideo(int m_UserID)
        {
            //用户视频横列显示规则
            int userCount = GetUserCount();

            if (userCount > 0 && userCount <= 1)
            {
                m_ColUserVideo = 1;
            }
            else if (userCount > 1 && userCount <= 4)
            {
                m_ColUserVideo = 2;
            }
            else if (userCount > 4)
            {
                m_ColUserVideo = 3;
            }

            int   m_PnlCount = pnl_video.Controls.Count;
            Panel m_ShowWnd  = new Panel();

            m_ShowWnd.Name         = m_UserID.ToString();
            m_ShowWnd.Width        = (pnl_video.Width) / m_ColUserVideo;
            m_ShowWnd.Height       = m_ShowWnd.Width * 4 / 5;
            m_ShowWnd.Top          = m_PnlCount / m_ColUserVideo * m_ShowWnd.Height + m_PnlCount / m_ColUserVideo * 5;
            m_ShowWnd.Left         = m_PnlCount % m_ColUserVideo * m_ShowWnd.Width + m_PnlCount % m_ColUserVideo * 5;
            m_ShowWnd.BackColor    = Color.Black;
            m_ShowWnd.DoubleClick += new EventHandler(ShowWnd_DoubleClick);
            m_ShowWnd.MouseEnter  += new EventHandler(m_ShowWnd_MouseEnter);
            m_ShowWnd.MouseLeave  += new EventHandler(m_ShowWnd_MouseLeave);
            pnl_video.Controls.Add(m_ShowWnd);
            AnyChatCoreSDK.SetVideoPos(m_UserID, m_ShowWnd.Handle, 0, 0, m_ShowWnd.Width, m_ShowWnd.Height);
            AnyChatCoreSDK.UserCameraControl(m_UserID, true);
            AnyChatCoreSDK.UserSpeakControl(m_UserID, true);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 初始化AnyChat sdk
        /// 注册 callback
        /// </summary>
        public static void Init(IntPtr hWnd)
        {
            AnyChatCoreSDK.ActiveCallLog(true);
            ulong dwFuncMode = AnyChatCoreSDK.BRAC_FUNC_VIDEO_AUTODISP
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOPLAY
                               | AnyChatCoreSDK.BRAC_FUNC_CHKDEPENDMODULE
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_VOLUMECALC
                               | AnyChatCoreSDK.BRAC_FUNC_NET_SUPPORTUPNP
                               | AnyChatCoreSDK.BRAC_FUNC_FIREWALL_OPEN
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOVOLUME
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_VOLUMECALC
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_CBDATA
                               | AnyChatCoreSDK.BRAC_FUNC_CONFIG_LOCALINI;

            ///初始化
            AnyChatCoreSDK.InitSDK(hWnd, dwFuncMode);

            ///注册回调
            ///视频
            AnyChatCoreSDK.SetVideoDataCallBack(AnyChatCoreSDK.PixelFormat.BRAC_PIX_FMT_RGB24,
                                                video_Callback, hWnd.ToInt32());
            //声音
            AnyChatCoreSDK.SetAudioDataCallBack(audio_Callback, hWnd.ToInt32());
            //文字
            AnyChatCoreSDK.SetTextMessageCallBack(text_Callback, hWnd.ToInt32());
            //透明通道
            AnyChatCoreSDK.SetTransBufferCallBack(transBuff_Callback, hWnd.ToInt32());
            //p2p文件传输
            AnyChatCoreSDK.SetTransFileCallBack(transFile_callback, hWnd.ToInt32());
            ///与服务器端数据回调
            AnyChatCoreSDK.SetSDKFilterDataCallBack(filterData_callback, hWnd.ToInt32());
            ///提供服务器端验证
            AnyChatCoreSDK.SetServerAuthPass(new StringBuilder(""));
        }
Ejemplo n.º 13
0
 //视频呼叫结束
 private void VideoCall_Finished_Handler(Bitmap bit, string strMsg)
 {
     OpenCameraAndSpeak(-1, false);
     OpenCameraAndSpeak(getOtherInSession(), false);
     AnyChatCoreSDK.LeaveRoom(-1);
     InitFaceAfterEndCall(bit, strMsg);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 通过用户ID获得用户账号
        /// </summary>
        /// <param name="m_UserID"></param>
        /// <returns></returns>
        private string GetUserNameByID(int m_UserID)
        {
            StringBuilder m_TempName = new StringBuilder(30);
            int           ret        = AnyChatCoreSDK.GetUserName(m_UserID, m_TempName, 30);//获取用户账号

            return(m_TempName.ToString());
        }
Ejemplo n.º 15
0
 // 拒绝视频呼叫邀请
 void btn_refuse_Click(object sender, EventArgs e)
 {
     //发送视频呼叫回复指令,dwErrcode=100104
     AnyChatCoreSDK.VideoCallControl(AnyChatCoreSDK.BRAC_VIDEOCALL_EVENT_REPLY, ConversationMode.SuserId, AC_ERROR_VIDEOCALL_REJECT, 0, 0, "");
     ConversationMode = null;
     InitFaceAfterEndCall(Properties.Resources._5, "已经拒绝会话...");
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 获取在线用户数量(不包括自己)
        /// </summary>
        /// <returns>在线用户数量</returns>
        private int GetUserCount()
        {
            int userCount = 0;

            //int[] ids = new int[] { };
            AnyChatCoreSDK.GetOnlineUser(null, ref userCount);
            return(userCount);
        }
Ejemplo n.º 17
0
 //窗体关闭
 private void Hall_FormClosed(object sender, FormClosedEventArgs e)
 {
     AnyChatCoreSDK.Logout();
     AnyChatCoreSDK.Release();
     Application.Exit();
     bReleased = true;
     //Login loginForm = new Login();
     //loginForm.Close();
 }
Ejemplo n.º 18
0
        //开始会话
        private void VideoCall_SessionStart_Handler(int roomId)
        {
            AnyChatCoreSDK.EnterRoom(roomId, "", 0);
            SoundPlayer Player = new SoundPlayer();

            Player.Stream = Properties.Resources.system;
            Player.Play();
            Player.Dispose();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 获取在线好友数据
        /// </summary>
        public void getOnlineFriendInfos()
        {
            users.Clear();
            InitUserPanl();
            UserInfo selfUserItem = new UserInfo();

            selfUserItem.Id   = m_UserId;
            selfUserItem.Name = m_UserName;

            byte[] ipByte = new byte[100];
            AnyChatCoreSDK.QueryUserState(selfUserItem.Id, AnyChatCoreSDK.BRAC_USERSTATE_INTERNETIP, ref ipByte[0], 20);
            selfUserItem.Ip = byteToString(ipByte);
            AddUser(selfUserItem);
            int num = 0;

            AnyChatCoreSDK.GetUserFriends(null, ref num);
            int[] friendIds = new int[num];
            AnyChatCoreSDK.GetUserFriends(friendIds, ref num);
            for (int i = 0; i < friendIds.Length; i++)
            {
                int onlineStatus = 0;
                int friendId     = friendIds[i];
                AnyChatCoreSDK.GetFriendStatus(friendId, ref onlineStatus);
                Log.SetLog("GetFriendStatus: " + "用户id:" + friendId + "在线状态:" + onlineStatus);
                if (onlineStatus == USER_OFFLINE)
                {
                    continue;
                }
                UserInfo userItem = new UserInfo();
                int      lenth    = 30;
                userItem.Id = friendId;
                byte[] userNameByte = new byte[255];
                AnyChatCoreSDK.GetUserInfo(friendId, USERDATA_USERNAME, ref userNameByte[0], lenth);
                string userName = byteToString(userNameByte);
                userItem.Name = userName;

                byte[] userAddressIPByte = new byte[100];
                AnyChatCoreSDK.GetUserInfo(friendId, USERDATA_USERADRESSIP, ref userAddressIPByte[0], lenth);
                string userIp = byteToString(userAddressIPByte);
                userItem.Ip = userIp;
                bool ishave = false;
                foreach (UserInfo u in users)
                {
                    if (u.Id == userItem.Id)
                    {
                        ishave = true;
                        break;
                    }
                }
                if (!ishave)
                {
                    users.Add(userItem);
                }
                AddUser(userItem);
            }
        }
Ejemplo n.º 20
0
 //窗体关闭
 private void Login_FormClosed(object sender, FormClosedEventArgs e)
 {
     try
     {
         AnyChatCoreSDK.Logout();
         AnyChatCoreSDK.Release();
     }
     catch (Exception ex)
     {
         Log.SetLog("QueueClient.Login.Login_FormClosed       Login_FormClosed:" + ex.Message.ToString());
     }
 }
Ejemplo n.º 21
0
        private void Received_TransBuffer(int userId, IntPtr buf, int len, int userValue)
        {
            //过滤信息()
            string m_Command = Marshal.PtrToStringAnsi(buf);

            try
            {
                if (m_Command.Length > 3)
                {
                    string[] m_Packet = m_Command.Split(":".ToCharArray());
                    //选择是否接收文件
                    if (m_Packet[0] == "003" && m_Packet[3] == "file")
                    {
                        int          m_TempUserID = Convert.ToInt32(m_Packet[1]);
                        string       m_pacName    = GetUserNameByID(m_TempUserID);
                        DialogResult r            = MessageBox.Show("文件名:" + m_Packet[2].ToString() + ",是否接收?", m_pacName + "发送文件请求", MessageBoxButtons.YesNo);
                        if (r == System.Windows.Forms.DialogResult.Yes)
                        {
                            FolderBrowserDialog fbd = new FolderBrowserDialog();
                            if (fbd.ShowDialog() == DialogResult.OK)
                            {
                                receivePath = fbd.SelectedPath;
                                string m_Message = "003:" + m_myUserID.ToString() + ":" + "fileisok:";
                                byte[] buffer    = Encoding.Default.GetBytes(m_Message);
                                int    rett      = AnyChatCoreSDK.TransBuffer(m_TempUserID, buffer, buffer.Length);
                            }
                        }
                        else
                        {
                            string m_Message = "003:" + m_myUserID.ToString() + ":" + "fileisno:" + m_Packet[2].ToString();
                            byte[] buffer    = Encoding.Default.GetBytes(m_Message);
                            int    rett      = AnyChatCoreSDK.TransBuffer(m_TempUserID, buffer, buffer.Length);
                        }
                    }
                    //发送文件
                    else if (m_Packet[0] == "003" && m_Packet[2] == "fileisok")
                    {
                        int taskId       = 0;
                        int m_TempUserID = Convert.ToInt32(m_Packet[1]);
                        int flag         = AnyChatCoreSDK.TransFile(m_TempUserID, sendPath, 1, 0, 0, ref taskId);
                        Print("成功发送" + sendPath + "文件");
                    }
                    else if (m_Packet[0] == "003" && m_Packet[2] == "fileisno")
                    {
                        string m_tempName = GetUserNameByID(Convert.ToInt32(m_Packet[1]));
                        Print(m_tempName + "拒绝接收文件" + m_Packet[3].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 22
0
        private void UpdateUserList(int m_UserID, int m_Index)
        {
            clsMemberList.MemberItem m_TempItem = new clsMemberList.MemberItem(); //创建用户在线列表(自定义,包含用户属性)
            StringBuilder            m_TempName = new StringBuilder(30);
            int ret = AnyChatCoreSDK.GetUserName(m_UserID, m_TempName, 30);       //获取用户账号

            m_TempItem.m_UserName   = m_TempName.ToString();
            m_TempItem.m_UserID     = m_UserID;
            m_TempItem.m_Index      = m_Index;
            m_TempItem.m_Permission = new int[] { 0, 0, 0 }; //用户权限
            m_MemberItem.Add(m_TempItem);                    //添加到在线用户列表
        }
Ejemplo n.º 23
0
        //单击登录
        private void btn_login_Click(object sender, EventArgs e)
        {
            //应用签名
            string signStr = string.Empty;
            //签名时间戳
            int signTimestamp = 0;

            try
            {
                if (tb_name.Text != "")
                {
                    string addr = "";
                    int    port = 8906;
                    try
                    {
                        addr       = tb_serveradd.Text;
                        port       = Convert.ToInt32(tb_port.Text);
                        m_userName = tb_name.Text;
                    }
                    catch (Exception)
                    {
                        ShowMessage("配置有误");
                    }
                    if (hallForm != null && !hallForm.bReleased)
                    {
                        AnyChatCoreSDK.Logout();
                        AnyChatCoreSDK.Release();
                    }
                    SystemSetting.Init(this.Handle);

                    /* AnyChat可以连接自主部署的服务器、也可以连接AnyChat视频云平台;
                     * 连接自主部署服务器的地址为自设的服务器IP地址或域名、端口;
                     * 连接AnyChat视频云平台的服务器地址为:cloud.anychat.cn;端口为:8906
                     */
                    AnyChatCoreSDK.Connect(addr, port);

                    /*
                     * AnyChat支持多种用户身份验证方式,包括更安全的签名登录,
                     * 详情请参考:http://bbs.anychat.cn/forum.php?mod=viewthread&tid=2211&highlight=%C7%A9%C3%FB
                     */
                    int ret = AnyChatCoreSDK.Login(m_userName, "123", 0);//登录系统
                }
                else
                {
                    ShowMessage("用户名不能为空");
                }
            }
            catch (Exception ex)
            {
                Log.SetLog("VideoChat.Login.btn_login_Click       btn_login_Click:" + ex.Message.ToString());
            }
        }
Ejemplo n.º 24
0
        void InitChat()
        {
            string path = Application.StartupPath;

            SystemSetting.Text_OnReceive     = new TextReceivedHandler(Received_Text);
            SystemSetting.TransFile_Received = new TransFileReceivedHandler(Received_TransFile);
            AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_CORESDK_PATH, path, path.Length);
            SystemSetting.Init(this.Handle);

            int ret = AnyChatCoreSDK.Connect("demo.anychat.cn", 8906);

            ret = AnyChatCoreSDK.Login("user2", "", 0);
        }
Ejemplo n.º 25
0
        //双击视频呼叫
        void user_DoubleClick(object sender, EventArgs e)
        {
            PictureBox user    = sender as PictureBox;
            UserInfo   mode    = user.Tag as UserInfo;
            int        tUserId = mode.Id;

            if (tUserId != m_UserId)
            {
                //发送视频呼叫,最后两个参数为自定义参数
                AnyChatCoreSDK.VideoCallControl(AnyChatCoreSDK.BRAC_VIDEOCALL_EVENT_REQUEST, tUserId, 0, 0, 0, m_UserName);
                intCallTimer = 10;
                ShowCallMessage(Properties.Resources._23, "正在发起呼叫请求...");
                timer_call.Start();
            }
        }
Ejemplo n.º 26
0
        int intTuserSpeakValue = 0; //被动方音量
        private void timer_speak_Tick(object sender, EventArgs e)
        {
            if (ConversationMode != null)
            {
                int value = 0;
                AnyChatCoreSDK.QueryUserState(ConversationMode.SuserId, AnyChatCoreSDK.BRAC_USERSTATE_SPEAKVOLUME, ref value, sizeof(int));
                intSuserSpeakValue = value;

                AnyChatCoreSDK.QueryUserState(ConversationMode.TuserId, AnyChatCoreSDK.BRAC_USERSTATE_SPEAKVOLUME, ref value, sizeof(int));
                intTuserSpeakValue = value;

                pic_tuserSound.Invalidate();
                pic_suserSound.Invalidate();
            }
        }
Ejemplo n.º 27
0
        private void BtnSend_Click(object sender, EventArgs e)
        {
            if (TbxSend.Text.Trim() == "")
            {
                MessageBox.Show("发送的消息内容不可以为空!");
            }
            else
            {
                string message = TbxSend.Text;
                int    length  = UnicodeEncoding.Default.GetBytes(message).Length;
                int    ret     = AnyChatCoreSDK.SendTextMessage(-1, false, message, length);
            }

            Print("我说:" + TbxSend.Text);
            TbxSend.Text = "";
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 发送透明通道
        /// </summary>
        /// <param name="tuserid">目标ID</param>
        /// <param name="cmd">指令ID</param>
        /// <param name="os">参数</param>
        /// <returns>调用结果</returns>
        internal int TranBuff(int tuserid, int cmd, params ParamInfo[] os)
        {
            int ret = -1;

            try
            {
                string strCmd = CommandHelp.GenerateCommand(cmd, os);
                byte[] buff   = Encoding.Default.GetBytes(strCmd);
                AnyChatCoreSDK.TransBuffer(tuserid, buff, buff.Length);
            }
            catch (Exception ex)
            {
                Log.SetLog("VideoChat.Hall.TranBuff       TranBuff:" + ex.Message.ToString());
            }
            return(ret);
        }
Ejemplo n.º 29
0
        private void stop_Click(object sender, RoutedEventArgs e)
        {
            if (_stopRecTimer != null)
            {
                _stopRecTimer.IsEnabled = false;
            }

            start.IsEnabled   = true;
            stop.IsEnabled    = false;
            preview.IsEnabled = true;
            save.IsEnabled    = true;

            AnyChatCoreSDK.StreamRecordCtrl(-1, false, 0, 0);
            //disapthcerTimer.IsEnabled = false;
            //_writer.Close();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 发送按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_sendtxt_Click(object sender, EventArgs e)
        {
            string m_Message = rtxt_sendtxt.Text;

            if (m_Message.Length == 0)
            {
                MessageBox.Show("发送文本不能为空", "提示");
                return;
            }


            int    length         = UnicodeEncoding.Default.GetBytes(m_Message).Length;
            int    m_TempUserID   = -1;
            string m_TempUserName = "******";

            if (dgv_onlineuser.SelectedRows.Count != 0)
            {
                DataGridViewRow dgvr = dgv_onlineuser.SelectedRows[0];
                m_TempUserName = dgvr.Cells["gvc_username"].Value.ToString();
                for (int i = 0; i < m_MemberItem.Count; i++)
                {
                    if (m_MemberItem[i].m_UserName == m_TempUserName)
                    {
                        m_TempUserID = m_MemberItem[i].m_UserID;
                        break;
                    }
                }
            }
            bool m_Secret = false;

            if (m_TempUserID != -1)
            {
                m_Secret = true;
            }
            int ret = AnyChatCoreSDK.SendTextMessage(m_TempUserID, m_Secret, m_Message, length);

            //显示聊天内容
            string m_DispMsg = "我 To   " + m_TempUserName + " ";

            ShowText(m_DispMsg, txt_Accept.TextLength, m_DispMsg.Length, Color.Green, new Font("黑体", 9, FontStyle.Bold));
            ShowText(DateTime.Now.ToString(), txt_Accept.TextLength, DateTime.Now.ToString().Length, Color.Green, new Font("黑体", 9, FontStyle.Bold));
            ShowText("\r\n", txt_Accept.TextLength, 4, Color.Blue, new Font("宋体", 12));
            ShowText("    ", txt_Accept.TextLength, 4, Color.Blue, new Font("宋体", 12));
            ShowText(m_Message, txt_Accept.TextLength, m_Message.Length, Color.Black, new Font("黑体", 9));
            ShowText("\r\n\r\n", txt_Accept.TextLength, 8, Color.Blue, new Font("宋体", 12));
            rtxt_sendtxt.Text = "";
        }