private void Button_Click(object sender, RoutedEventArgs e) { try { if (!IsConnected) { AudioChat = new AudioChat(IPAddress.Parse(Ip.Text)); GroupChat = new GroupChat(IPAddress.Parse(Ip.Text)); FileChat = new FileChat(IPAddress.Parse(Ip.Text)); GroupChat.OnMessage += GroupChat_OnMessage; FileChat.OnMessage += FileChat_OnMessage; GroupChat.ReceiveAsync(); FileChat.ReceiveAsync(); } else { CloseConnection(); } IsConnected = !IsConnected; ScreenCastGrid.IsEnabled = IsConnected; GridChats.IsEnabled = IsConnected; ChangeButtonState((Button)sender); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 初始化 /// </summary> /// <param name="sendOrReceive"></param> private void InitAudio(GlobalVariable.AudioSendOrReceive sendOrReceive) { if (sendOrReceive == GlobalVariable.AudioSendOrReceive.Send) { Title = $"正在呼叫{_targetUser.userName}..."; AcceptVisibility = Visibility.Collapsed; SetStanckPanel(true); var targetAccid = _targetUser.accid; if (string.IsNullOrEmpty(targetAccid)) { QueryUserInfo(_targetUser.userId); } AudioChat.Start(_targetUser.accid, NIMVideoChatMode.kNIMVideoChatModeAudio); //构造一条语音电话消息 AudioChat.targetUid = _targetUser.userId; } else { Title = $"正在与{_targetUser.userName}通话中..."; Countdown(); SetStanckPanel(false); } SetContactPhoto(); AudioChat.SetAudioPlayVolumn(120); }
protected virtual void OnLoginSuccess() { //NotifyIconControl.Instance.notifyIcon.ContextMenu.MenuItems["ExitApp"].Click -= ItemExitClick; //NotifyIconControl.Instance.notifyIcon.MouseClick -= OnNotifyIconMouseClick; //NotifyIconControl.Instance.notifyIcon.Visible = false; //this.LoginSuccessEvent?.Invoke(); System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); System.Windows.Application.Current.Dispatcher.Invoke(() => { MainWindowViewModel model = new MainWindowViewModel(); var result = model.GetGroupList(); if (!result) { loginCount++; //如果尝试3获取数据失败,返回登录页面 if (loginCount >= 3) { MessageBoxWindow.Show("尝试多次获取群数据失败,请联系管理员。", GlobalVariable.WarnOrSuccess.Warn); if (IsLoginSuccess) { var errorCode = 0; var errorMsg = string.Empty; //发送状态 AntSdkService.AntSdkUpdateCurrentUserState((int)GlobalVariable.OnLineStatus.OffLine, ref errorCode, ref errorMsg); //停止SDK SDK.AntSdk.AntSdkService.StopAntSdk(ref errorCode, ref errorMsg); AudioChat.ExitClearApi(); } System.Windows.Application.Current.Shutdown(); CommonMethods.StartApplication(System.Windows.Forms.Application.StartupPath + "/AntennaChat.exe"); return; } OnLoginSuccess(); return; } //model.DownloadUserHeadImage(); MainWindowView mainWindow = new MainWindowView { DataContext = model }; //model.InitMainVM(); if (this.LoginWindow != null) { var loginWindow = LoginWindow as LoginWindowView; loginWindow?.taskbarIcon.Dispose(); } loginCount = 0; mainWindow.Show(); GlobalVariable.LastLoginDatetime = DateTime.Now; this.LoginWindow?.Close(); }); stopWatch.Stop(); Antenna.Framework.LogHelper.WriteDebug($"[Model_LoginSuccessEvent({stopWatch.Elapsed.TotalMilliseconds}毫秒)]"); }
/// <summary> /// 拒绝 /// </summary> public void RefuseAudio() { if (!AntSdkService.AntSdkIsConnected) { MessageBoxWindow.Show("提示", "网络连接已断开,无法进行语音电话!", MessageBoxButton.OK, GlobalVariable.WarnOrSuccess.Warn); AudioChat._currentChannelId = 0; CloseWin(); return; } AudioChat.AudioResult(ModelId, false); AudioChat._currentChannelId = 0; CloseWin(); }
/// <summary> /// 调节音量 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void RangeBase_OnValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { var volumnSlider = sender as System.Windows.Controls.Slider; if (volumnSlider == null) { return; } var value = Convert.ToInt32(volumnSlider.Value); AudioChat.SetAudioPlayVolumn(value); _currentVolunm = value; }
private void Login() { if (!Param.IsLoginValidate) { LoginVisibility = Visibility.Visible; IsLogining = Visibility.Collapsed; this.TipsLabelText = string.Format("该账号已经登录,不能重复登录"); this.TipsPopuIsOpen = true; return; } string errMsg = string.Empty; ThreadPool.QueueUserWorkItem(o => { lock (loginLock) { if (IsLoginSuccess == true) { return; } if (Login(LoginID, LoginPwd, ref errMsg)) { IsLoginSuccess = true; //初始化网易云信SDK if (!AudioChat.InitApi()) { return; } ThreadPool.QueueUserWorkItem(m => FileHelper.DownloadUserHeadImage()); OnLoginSuccess(); } else { LoginVisibility = Visibility.Visible; IsLogining = Visibility.Collapsed; this.TipsLabelText = string.Format("登录失败:{0}", errMsg); this.TipsPopuIsOpen = true; App.Current.Dispatcher.Invoke((Action)(() => { Timing(); })); } } }); }
// Start is called before the first frame update void Start() { audioChat = GetComponent <AudioChat>(); }