Repository: discordjs/discord.js
File: packages/voice/src/networking/DAVESession.ts (TypeScript)

Code before:
 * Generally, transitions last about 3 seconds maximum, but this should cover for when connections are delayed.
 */
const TRANSITION_EXPIRY_PENDING_DOWNGRADE = 24;

/**
 * The amount of packets to allow decryption failure for until we deem the transition bad and re-initialize.
 * Usually 4 packets on a good connection may slip past when entering a new session.
 * After re-initializing, 5-24 packets may fail to decrypt after.
 */
export const DEFAULT_DECRYPTION_FAILURE_TOLERANCE = 36;

interface TransitionResult {
	success: boolean;
	transitionId: number;
}
/**
 * Options that dictate the session behavior.
 */
export interface DAVESessionOptions {
	decryptionFailureTolerance?: number | undefined;
}

/**
 * The maximum DAVE protocol version supported.
 */
export function getMaxProtocolVersion(): number | null {
	return Davey.DAVE_PROTOCOL_VERSION;
}

export interface DAVESession extends EventEmitter {
	on(event: 'error', listener: (error: Error) => void): this;
	on(event: 'debug', listener: (message: string) => void): this;
	on(event: 'keyPackage', listener: (message: Buffer) => void): this;
	on(event: 'invalidateTransition', listener: (transitionId: number) => void): this;
}

/**
 * Manages the DAVE protocol group session.
 */
export class DAVESession extends EventEmitter {
	/**
	 * The channel id represented by this session.
	 */
	public channelId: string;

	/**
	 * The user id represented by this session.
	 */
	public userId: string;

	/**

Review comment (bug):
There is also more redudant code involving `getMaxProtocolVersion()` in the Networking class, since this no longer returns `null` (it actually never returned null, that was typed incorrectly, it used to return `undefined`)

```suggestion
export function getMaxProtocolVersion(): number {
```

Code after:
 * Generally, transitions last about 3 seconds maximum, but this should cover for when connections are delayed.
 */
const TRANSITION_EXPIRY_PENDING_DOWNGRADE = 24;

/**
 * The amount of packets to allow decryption failure for until we deem the transition bad and re-initialize.
 * Usually 4 packets on a good connection may slip past when entering a new session.
 * After re-initializing, 5-24 packets may fail to decrypt after.
 */
export const DEFAULT_DECRYPTION_FAILURE_TOLERANCE = 36;

interface TransitionResult {
	success: boolean;
	transitionId: number;
}
/**
 * Options that dictate the session behavior.
 */
export interface DAVESessionOptions {
	decryptionFailureTolerance?: number | undefined;
}

/**
 * The maximum DAVE protocol version supported.
 */
export function getMaxProtocolVersion(): number {
	return Davey.DAVE_PROTOCOL_VERSION;
}

export interface DAVESession extends EventEmitter {
	on(event: 'error', listener: (error: Error) => void): this;
	on(event: 'debug', listener: (message: string) => void): this;
	on(event: 'keyPackage', listener: (message: Buffer) => void): this;
	on(event: 'invalidateTransition', listener: (transitionId: number) => void): this;
}

/**
 * Manages the DAVE protocol group session.
 */
export class DAVESession extends EventEmitter {
	/**
	 * The channel id represented by this session.
	 */
	public channelId: string;

	/**
	 * The user id represented by this session.
	 */
	public userId: string;

	/**