Beispiel #1
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
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// 退出程序清理
 /// </summary>
 public static void ExitClearApi()
 {
     //退出前需要结束音视频设备,防止错误的数据上报\
     if (_devicesIsStart)
     {
         EndDevices();
     }
     if (!IsInit)
     {
         return;
     }
     System.Threading.Thread.Sleep(500);
     //在释放前需要按步骤清理音视频模块和nim client模块
     VChatAPI.Cleanup();
     System.Threading.Semaphore s = new System.Threading.Semaphore(0, 1);
     Logout(NIMLogoutType.kNIMLogoutAppExit, (r) =>
     {
         s.Release();
     });
     //需要logout执行完才能退出程序
     s.WaitOne(TimeSpan.FromSeconds(10));
     ClientAPI.Cleanup();
 }