Table of Contents

Class VoiceClient

Namespace
NetCord.Gateway.Voice
Assembly
NetCord.dll
public sealed class VoiceClient : WebSocketClient, IDisposable
Inheritance
VoiceClient
Implements
Inherited Members

Constructors

VoiceClient(ulong, string, string, ulong, ulong, string, VoiceClientConfiguration?)

public VoiceClient(ulong userId, string sessionId, string endpoint, ulong guildId, ulong channelId, string token, VoiceClientConfiguration? configuration = null)

Parameters

userId ulong
sessionId string
endpoint string
guildId ulong
channelId ulong
token string
configuration VoiceClientConfiguration

Properties

Cache

The cache of the VoiceClient.

public IVoiceClientCache Cache { get; }

Property Value

IVoiceClientCache

ChannelId

public ulong ChannelId { get; }

Property Value

ulong

Endpoint

public string Endpoint { get; }

Property Value

string

GuildId

public ulong GuildId { get; }

Property Value

ulong

SequenceNumber

The sequence number of the VoiceClient.

public int SequenceNumber { get; }

Property Value

int

SessionId

public string SessionId { get; }

Property Value

string

Token

public string Token { get; }

Property Value

string

UserId

public ulong UserId { get; }

Property Value

ulong

Methods

CreateVoiceStream(VoiceStreamConfiguration?)

Creates a stream that you can write to to send voice. Each write must be exactly one Opus frame.

public Stream CreateVoiceStream(VoiceStreamConfiguration? configuration = null)

Parameters

configuration VoiceStreamConfiguration

The configuration of the voice stream.

Returns

Stream

Dispose(bool)

protected override void Dispose(bool disposing)

Parameters

disposing bool

EnterSpeakingStateAsync(SpeakingProperties, WebSocketPayloadProperties?, CancellationToken)

public ValueTask EnterSpeakingStateAsync(SpeakingProperties speaking, WebSocketPayloadProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

speaking SpeakingProperties
properties WebSocketPayloadProperties
cancellationToken CancellationToken

Returns

ValueTask

ResumeAsync(int, CancellationToken)

Resumes the session.

public ValueTask ResumeAsync(int sequenceNumber, CancellationToken cancellationToken = default)

Parameters

sequenceNumber int

The sequence number of the payload to resume from.

cancellationToken CancellationToken

The cancellation token to cancel the operation.

Returns

ValueTask

SendVoice(ushort, uint, ReadOnlySpan<byte>)

Sends a voice frame.

public void SendVoice(ushort sequenceNumber, uint timestamp, ReadOnlySpan<byte> frame)

Parameters

sequenceNumber ushort

The sequence number of the voice frame.

timestamp uint

The timestamp of the voice frame.

frame ReadOnlySpan<byte>

The Opus voice frame to send.

SendVoiceAsync(ushort, uint, ReadOnlyMemory<byte>, CancellationToken)

Sends a voice frame.

public ValueTask SendVoiceAsync(ushort sequenceNumber, uint timestamp, ReadOnlyMemory<byte> frame, CancellationToken cancellationToken = default)

Parameters

sequenceNumber ushort

The sequence number of the voice frame.

timestamp uint

The timestamp of the voice frame.

frame ReadOnlyMemory<byte>

The Opus voice frame to send.

cancellationToken CancellationToken

A cancellation token that can be used to cancel the send operation.

Returns

ValueTask

StartAsync(CancellationToken)

Starts the VoiceClient.

public ValueTask StartAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask

Events

Ready

public event Func<ValueTask>? Ready

Event Type

Func<ValueTask>

Speaking

public event Func<SpeakingEventArgs, ValueTask>? Speaking

Event Type

Func<SpeakingEventArgs, ValueTask>

UserConnect

public event Func<UserConnectEventArgs, ValueTask>? UserConnect

Event Type

Func<UserConnectEventArgs, ValueTask>

UserDisconnect

public event Func<UserDisconnectEventArgs, ValueTask>? UserDisconnect

Event Type

Func<UserDisconnectEventArgs, ValueTask>

VoiceReceive

public event Func<VoiceReceiveEventArgs, ValueTask>? VoiceReceive

Event Type

Func<VoiceReceiveEventArgs, ValueTask>