You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

IAudioClient.cs 2.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Discord.Net.Rest;
  2. using Discord.Net.WebSockets;
  3. using System.IO;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. namespace Discord.Audio
  7. {
  8. public interface IAudioClient
  9. {
  10. /// <summary> Gets the unique identifier for this client. </summary>
  11. int Id { get; }
  12. /// <summary> Gets the session id for the current connection. </summary>
  13. string SessionId { get; }
  14. /// <summary> Gets the current state of this client. </summary>
  15. ConnectionState State { get; }
  16. /// <summary> Gets the channel this client is currently a member of. </summary>
  17. Channel Channel { get; }
  18. /// <summary> Gets the server this client is bound to. </summary>
  19. Server Server { get; }
  20. /// <summary> Gets a stream object that wraps the Send() function. </summary>
  21. Stream OutputStream { get; }
  22. /// <summary> Gets a cancellation token that triggers when the client is manually disconnected. </summary>
  23. CancellationToken CancelToken { get; }
  24. /// <summary> Gets the internal RestClient for the Client API endpoint. </summary>
  25. RestClient ClientAPI { get; }
  26. /// <summary> Gets the internal WebSocket for the Gateway event stream. </summary>
  27. GatewaySocket GatewaySocket { get; }
  28. /// <summary> Gets the internal WebSocket for the Voice control stream. </summary>
  29. VoiceSocket VoiceSocket { get; }
  30. /// <summary> Moves the client to another channel on the same server. </summary>
  31. Task Join(Channel channel);
  32. /// <summary> Disconnects from the Discord server, canceling any pending requests. </summary>
  33. Task Disconnect();
  34. /// <summary> Sends a PCM frame to the voice server. Will block until space frees up in the outgoing buffer. </summary>
  35. /// <param name="data">PCM frame to send. This must be a single or collection of uncompressed 48Kz monochannel 20ms PCM frames. </param>
  36. /// <param name="offset">Offset . </param>
  37. /// <param name="count">Number of bytes in this frame. </param>
  38. void Send(byte[] data, int offset, int count);
  39. /// <summary> Clears the PCM buffer. </summary>
  40. void Clear();
  41. /// <summary> Blocks until the voice output buffer is empty. </summary>
  42. void Wait();
  43. }
  44. }