internal VoiceConnection(Channel channel, VoiceGateway voice) { _channelId = channel.Id; Bot = channel.Bot; VoiceGateway = voice; VoiceGateway.OnStop += (a, b) => { Disconnect(); }; if (!VoiceGateway.Running) { VoiceGateway.Start(); } while (!VoiceGateway.Ready) { Thread.Sleep(200); } AudioStreamer = VoiceGateway.CreateAudioStreamer(); AudioStreamer.OnAudioStart += (a, b) => { OnPlayAudio?.Invoke(this, EventArgs.Empty); }; AudioStreamer.OnAudioStop += (a, b) => { OnStopAudio?.Invoke(this, EventArgs.Empty); }; }
private void Stop() { participants.Clear(); gateway.Stop(); UnregisterClientEvents(); session = null; gateway = null; SetProgress(VoiceGateway.ConnectionState.None); GC.Collect(); }
private void Start() { if (gateway == null) { gateway = new VoiceGateway(instance.Client); } // Initialize progress bar progressBar1.Maximum = (int)VoiceGateway.ConnectionState.SessionRunning; SetProgress(0); RegisterClientEvents(); gateway.Start(); }
public Task Disconnect() { if (Guild == null) { Logger.Warn("Attempted to disconnect a voice connection, but was unable to locate the guild. Assuming connection has already closed."); return(Task.CompletedTask); } lock (Guild.VoiceLock) { if (VoiceGateway != null && VoiceGateway.Running) { VoiceGateway.Stop().Wait(); } if (Guild.VoiceConnection == this) { Guild.VoiceConnection = null; } } return(Task.CompletedTask); }
/// <summary> /// This command is used to start the audio capture process which will cause /// AuxAudioProperty Events to be raised. These events can be used to display a /// microphone VU meter for the currently selected capture device. This command /// should not be issued if the user is on a call. /// </summary> /// <param name="Duration">(unused but required)</param> /// <returns></returns> public int AuxCaptureAudioStart(int Duration) { string RequestXML = VoiceGateway.MakeXML("Duration", Duration.ToString()); return(Request("Aux.CaptureAudioStart.1", RequestXML)); }
/// <summary> /// This command is used to select the capture device. /// </summary> /// <param name="CaptureDeviceSpecifier">The name of the device as returned by the Aux.GetCaptureDevices command.</param> public int AuxSetCaptureDevice(string CaptureDeviceSpecifier) { string RequestXML = VoiceGateway.MakeXML("CaptureDeviceSpecifier", CaptureDeviceSpecifier); return(Request("Aux.SetCaptureDevice.1", RequestXML)); }
/// <summary> /// This command is used to set the speaker volume while in the audio tuning /// process. Once an acceptable speaker level is attained, the application must /// issue a connector set speaker volume command to have that level be used while /// on voice calls. /// </summary> /// <param name="Level">the speaker volume (-100 to 100 inclusive)</param> /// <returns></returns> public int AuxSetSpeakerLevel(int Level) { string RequestXML = VoiceGateway.MakeXML("Level", Level.ToString()); return(Request("Aux.SetSpeakerLevel.1", RequestXML)); }