Table of Contents

Class VoiceClient

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

Constructors

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

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

Parameters

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

Properties

Cache

The cache of the VoiceClient.

public IVoiceClientCache Cache { get; }

Property Value

IVoiceClientCache

Endpoint

public string Endpoint { get; }

Property Value

string

GuildId

public ulong GuildId { get; }

Property Value

ulong

RedirectInputStreams

public bool RedirectInputStreams { get; }

Property Value

bool

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

CreateOutputStream(bool)

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

public Stream CreateOutputStream(bool normalizeSpeed = true)

Parameters

normalizeSpeed bool

Whether to normalize the voice sending speed.

Returns

Stream

Exceptions

InvalidOperationException

Used before Ready event.

Dispose(bool)

protected override void Dispose(bool disposing)

Parameters

disposing bool

EnterSpeakingStateAsync(SpeakingFlags, int, WebSocketPayloadProperties?, CancellationToken)

public ValueTask EnterSpeakingStateAsync(SpeakingFlags flags, int delay = 0, WebSocketPayloadProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

flags SpeakingFlags
delay int
properties WebSocketPayloadProperties
cancellationToken CancellationToken

Returns

ValueTask

ResumeAsync(int, CancellationToken)

Resumes the session.

public Task 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

Task

StartAsync(CancellationToken)

Starts the VoiceClient.

public Task StartAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task

Events

Ready

public event Func<ValueTask>? Ready

Event Type

Func<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>