Ejemplo n.º 1
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.º 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 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.º 4
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.º 5
0
        private void buttonStart_Click(object sender, RoutedEventArgs e)
        {
            // 设置回调函数
            AnyChatCoreSDK.SetNotifyMessageCallBack(OnNotifyMessageCallback, 0);
            AnyChatCoreSDK.SetVideoDataCallBack(AnyChatCoreSDK.PixelFormat.BRAC_PIX_FMT_RGB24, OnVideoDataCallback, 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;

            // 初始化SDK
            AnyChatCoreSDK.InitSDK(IntPtr.Zero, dwFuncMode);
            AnyChatCoreSDK.Connect("demo.anychat.cn", 8906);
            AnyChatCoreSDK.Login("WFP", "", 0);
            AnyChatCoreSDK.EnterRoom(1, "", 0);


            NotifyMessageHandler = new AnyChatCoreSDK.NotifyMessage_CallBack(NotifyMessageCallbackDelegate);
            VideoDataHandler     = new AnyChatCoreSDK.VideoData_CallBack(VideoDataCallbackDelegate);
        }
Ejemplo n.º 6
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == AnyChatCoreSDK.WM_GV_CONNECT)
            {
                ///连接
                int succed = m.WParam.ToInt32();
                if (succed == 1)
                {
                    int ret = AnyChatCoreSDK.Login(m_userName, "123", 0);    //登录系统
                    ShowMessage("连接AnyChat服务器成功,正在登录系统...");
                }
                else
                {
                    ShowMessage("连接AnyChat服务器失败");
                    Log.SetLog("WM_GV_CONNECT      连接AnyChat服务器失败");
                }
            }
            else if (m.Msg == AnyChatCoreSDK.WM_GV_LOGINSYSTEM)
            {
                ///登录系统
                if (m.LParam.ToInt32() == 0)
                {
                    ShowMessage("登录AnyChat系统成功");
                    m_userId = m.WParam.ToInt32();    //保存当前ID
                    hallForm = null;
                    //hallForm = new Hall(m_userId, cbox_userIdentity.Text);
                    LoginInfo loginInfo = new LoginInfo();
                    loginInfo.userID       = m_userId;
                    loginInfo.userName     = m_userName;
                    loginInfo.userIdType   = m_userIdentity;
                    loginInfo.userPriority = m_identityPriority;
                    loginInfo.isRouterMode = m_isAutoRouter;
                    loginInfo.userSkills   = m_skillsValue;

                    hallForm = new frmHall(loginInfo, this);
                    this.Hide();
                    hallForm.Show();
                }
                else
                {
                    ShowMessage("登录失败:Error=" + m.LParam.ToString());
                    Log.SetLog("WM_GV_LOGINSYSTEM          登录失败:Error=" + m.LParam.ToString());
                }
            }
            else if (m.Msg == AnyChatCoreSDK.WM_GV_ENTERROOM)
            {
                //进入房间
                int lparam = m.LParam.ToInt32();
                if (lparam == 0)
                {
                    hallForm.EnterRoomSuccess();     //通知大厅进入房间成功
                }
                else
                {
                    Log.SetLog("WM_GV_ENTERROOM                进入房间,失败,Error:" + lparam.ToString());
                }
            }
            else if (m.Msg == AnyChatCoreSDK.WM_GV_ONLINEUSER)
            {
                hallForm.OpenCameraAndSpeak(hallForm.getOtherInSession(), true);    //打开视频呼叫对象的视频
            }
            //用户进入或者离开房间
            else if (m.Msg == AnyChatCoreSDK.WM_GV_USERATROOM)
            {
                int lparam = m.LParam.ToInt32();
                int wparam = m.WParam.ToInt32();
                if (lparam == 0)
                {
                    hallForm.OpenCameraAndSpeak(hallForm.getOtherInSession(), false);   //关闭视频呼叫对象的视频
                    Log.SetLog("WM_GV_USERATROOM           用户" + wparam.ToString() + "离开房间");
                }
                else
                {
                    hallForm.OpenCameraAndSpeak(hallForm.getOtherInSession(), true);    //打开视频呼叫对象的视频
                    Log.SetLog("WM_GV_USERATROOM           用户" + wparam.ToString() + "进入房间");
                }
            }
            //摄像头打开状态
            else if (m.Msg == AnyChatCoreSDK.WM_GV_CAMERASTATE)
            {
            }
            //网络断开
            else if (m.Msg == AnyChatCoreSDK.WM_GV_LINKCLOSE)
            {
                AnyChatCoreSDK.LeaveRoom(-1);
                int wparam = m.WParam.ToInt32();
                int lparam = m.LParam.ToInt32();
                ShowMessage("网络断开,ErrorCode:" + wparam.ToString());
                if (hallForm != null)
                {
                    hallForm.Hide();
                }
                this.Show();
                Log.SetLog("WM_GV_LINKCLOSE            响应网络断开,errorcode:=" + lparam);
            }
            base.WndProc(ref m);
        }
Ejemplo n.º 7
0
        //单击登录
        private void btn_login_Click(object sender, EventArgs e)
        {
            try
            {
                if (cbox_userIdentity.Text != "")
                {
                    string addr = "";
                    int    port = 8906;
                    try
                    {
                        addr               = cbox_serverIP.Text;
                        port               = Convert.ToInt32(cbox_port.Text);
                        m_userName         = cbox_userName.Text;
                        m_userIdentity     = (UserIdentityType)cbox_userIdentity.SelectedIndex;
                        m_identityPriority = Int32.Parse(cbox_identityPriority.Text);
                        if (m_userIdentity == UserIdentityType.Agent)
                        {
                            if (cmbBox_Router.SelectedIndex == 1)
                            {
                                m_isAutoRouter = true;
                            }
                            else
                            {
                                m_isAutoRouter = false;
                            }
                        }
                    }
                    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);//登录系统

                    RecordLoginTrace();
                }
                else
                {
                    ShowMessage("用户名不能为空");
                }
            }
            catch (Exception ex)
            {
                Log.SetLog("QueueClient.Login.btn_login_Click       btn_login_Click:" + ex.Message.ToString());
                ShowMessage(ex.Message.ToString());
            }
        }
Ejemplo n.º 8
0
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == AnyChatCoreSDK.WM_GV_CONNECT)
     {
         ///连接
         int succed = m.WParam.ToInt32();
         if (succed == 1)
         {
             //透明通道回调
             SystemSetting.TransBuffer_OnReceive = new TransBufferReceivedHandler(TransBuffer_CallBack);
             int ret = AnyChatCoreSDK.Login(m_userName, "123", 0);    //登录系统
             ShowMessage("连接AnyChat服务器成功,正在登录系统...");
         }
         else
         {
             ShowMessage("连接AnyChat服务器失败");
             Log.SetLog("WM_GV_CONNECT      连接AnyChat服务器失败");
         }
     }
     else if (m.Msg == AnyChatCoreSDK.WM_GV_LOGINSYSTEM)
     {
         ///登录系统
         if (m.LParam.ToInt32() == 0)
         {
             ShowMessage("登录AnyChat系统成功");
             m_userId = m.WParam.ToInt32();    //保存当前ID
             RecordLoginTrace();
             hallForm = null;
             hallForm = new Hall(m_userId, tb_name.Text);
             this.Hide();
             hallForm.Show();
         }
         else
         {
             ShowMessage("登录失败:Error=" + m.LParam.ToString());
             Log.SetLog("WM_GV_LOGINSYSTEM          登录失败:Error=" + m.LParam.ToString());
         }
     }
     else if (m.Msg == AnyChatCoreSDK.WM_GV_ENTERROOM)
     {
         //进入房间
         int lparam = m.LParam.ToInt32();
         if (lparam == 0)
         {
             hallForm.EnterRoomSuccess();     //通知大厅进入房间成功
         }
         else
         {
             Log.SetLog("WM_GV_ENTERROOM                进入房间,失败,Error:" + lparam.ToString());
         }
     }
     else if (m.Msg == AnyChatCoreSDK.WM_GV_ONLINEUSER)
     {
         hallForm.OpenCameraAndSpeak(hallForm.getOtherInSession(), true);    //打开视频呼叫对象的视频
     }
     //用户进入或者离开房间
     else if (m.Msg == AnyChatCoreSDK.WM_GV_USERATROOM)
     {
         int lparam = m.LParam.ToInt32();
         int wparam = m.WParam.ToInt32();
         if (lparam == 0)
         {
             hallForm.OpenCameraAndSpeak(hallForm.getOtherInSession(), false);   //关闭视频呼叫对象的视频
             Log.SetLog("WM_GV_USERATROOM           用户" + wparam.ToString() + "离开房间");
         }
         else
         {
             hallForm.OpenCameraAndSpeak(hallForm.getOtherInSession(), true);    //打开视频呼叫对象的视频
             Log.SetLog("WM_GV_USERATROOM           用户" + wparam.ToString() + "进入房间");
         }
     }
     //摄像头打开状态
     else if (m.Msg == AnyChatCoreSDK.WM_GV_CAMERASTATE)
     {
     }
     //网络断开
     else if (m.Msg == AnyChatCoreSDK.WM_GV_LINKCLOSE)
     {
         AnyChatCoreSDK.LeaveRoom(-1);
         int wparam = m.WParam.ToInt32();
         int lparam = m.LParam.ToInt32();
         ShowMessage("网络断开,ErrorCode:" + wparam.ToString());
         hallForm.Hide();
         this.Show();
         Log.SetLog("WM_GV_LINKCLOSE            响应网络断开,errorcode:=" + lparam);
     }
     //好友用户在线状态变化
     else if (m.Msg == AnyChatCoreSDK.WM_GV_FRIENDSTATUS)
     {
         int userId       = m.WParam.ToInt32();
         int onlineStatus = m.LParam.ToInt32();
         hallForm.OnUserOnlineStatusChange(userId, onlineStatus);
         string strOnlineStatus = onlineStatus >= 1? "上线":"下线";
         Log.SetLog("WM_GV_FRIENDSTATUS:  useId: " + userId + "onlineStatus:  " + strOnlineStatus);
     }
     //好友数据更新变化通知
     else if (m.Msg == AnyChatCoreSDK.WM_GV_USERINFOUPDATE)
     {
         int userId = m.WParam.ToInt32();
         int type   = m.LParam.ToInt32();
         if (userId == 0 && type == 0)
         {
             hallForm.getOnlineFriendInfos();
         }
         Log.SetLog("WM_GV_FRIENDSTATUS:  useId: " + userId + "type:  " + type);
     }
     base.WndProc(ref m);
 }