Example #1
0
        static void OnLoginResultCallback(string jsonResult, IntPtr ptr)
        {
            var loginResult = NIMLoginResult.Deserialize(jsonResult);

            ptr.Invoke <LoginResultDelegate>(loginResult);
            if (LoginResultHandler != null)
            {
                LoginResultHandler(null, new LoginResultEventArgs(loginResult));
            }
        }
Example #2
0
 /// <summary>
 /// 登录结果处理
 /// </summary>
 /// <param name="result"></param>
 private static void HandleLoginResult(NIM.NIMLoginResult result)
 {
     if (result.LoginStep == NIM.NIMLoginStep.kNIMLoginStepLogin)
     {
         //登录成功
         if (result.Code == NIM.ResponseCode.kNIMResSuccess)
         {
             if (!NIM.VChatAPI.Init())
             {
                 NimUtility.Log.Error("音视频通话功能初始化失败");
                 LogHelper.WriteError("音视频通话功能初始化失败");
                 ErrorMsg = "音视频通话功能初始化失败";
                 IsInit   = false;
                 #region 登出->清理API
                 System.Threading.Semaphore s = new System.Threading.Semaphore(0, 1);
                 Logout(NIMLogoutType.kNIMLogoutAppExit, (r) =>
                 {
                     s.Release();
                 });
                 //需要logout执行完才能退出程序
                 s.WaitOne(TimeSpan.FromSeconds(10));
                 ClientAPI.Cleanup();
                 #endregion
                 return;
             }
             IsInit = true;
             LogHelper.WriteDebug("音视频通话功能初始化成功.");
             InitVChatInfo();
         }
         else
         {
             NimUtility.Log.Error("音视频通话API登录失败");
             LogHelper.WriteError("音视频通话API登录失败");
             ErrorMsg = "音视频通话API登录失败";
             IsInit   = false;
             #region 登出->清理API
             System.Threading.Semaphore s = new System.Threading.Semaphore(0, 1);
             Logout(NIMLogoutType.kNIMLogoutChangeAccout, (r) =>
             {
                 s.Release();
             });
             //需要logout执行完才能退出程序
             s.WaitOne(TimeSpan.FromSeconds(10));
             ClientAPI.Cleanup();
             #endregion
         }
     }
 }
Example #3
0
        /// <summary>
        /// 登录结果处理
        /// </summary>
        /// <param name="result"></param>
        private void HandleLoginResult(NIM.NIMLoginResult result)
        {
            DemoTrace.WriteLine(result.LoginStep.ToString());
            Action action = () =>
            {
                if (result.LoginStep == NIM.NIMLoginStep.kNIMLoginStepLogin)
                {
                    if (result.Code == NIM.ResponseCode.kNIMResSuccess)
                    {
                        this.Hide();
                        new MainForm(_userName).Show();


                        //PublishLoginEvent();
                    }
                    else
                    {
                        // NIM.ClientAPI.Logout(NIM.NIMLogoutType.kNIMLogoutChangeAccout, HandleLogoutResult);
                    }
                }
            };

            this.Invoke(action);
        }
Example #4
0
 public LoginResultEventArgs(NIMLoginResult result)
 {
     LoginResult = result;
 }