Skip to content

~.server

Server

Protocol

Protocol(
    ip_discover_future: asyncio.Future[bytes],
    rtp_listener: Callable[[int], None],
)

Bases: asyncio.DatagramProtocol

Background UDP protocol for communication with Discord's voice servers.

Create a UDP server protocol.

PARAMETER DESCRIPTION
ip_discover_future

The future to set when our IP is discovered.

TYPE: asyncio.Future[bytes]

rtp_listener

The callback to call when we receive a non-IP discovery packet.

TYPE: Callable[[int], None]

connection_made

connection_made(
    transport: asyncio.DatagramTransport,
) -> None

Called automatically when a UDP connection is made.

PARAMETER DESCRIPTION
transport

The UDP transport.

TYPE: asyncio.DatagramTransport

datagram_received

datagram_received(
    data: bytes, address: tuple[str, int]
) -> None

Automatically called when we receive a UDP packet.

PARAMETER DESCRIPTION
data

The UDP packet data

TYPE: bytes

address

The address that sent this packet.

TYPE: tuple[str, int]

error_received

error_received(exc: Exception)

Automatically called when an error occurs.

PARAMETER DESCRIPTION
exc

The error that occurred.

TYPE: Exception

VoiceServer

VoiceServer(connection: VoiceConnection)

The background server responsible for communicating with Discord's voice servers.

Create a new voice server connection.

PARAMETER DESCRIPTION
connection

The voice connection handling this server.

TYPE: VoiceConnection

connect async

connect(ip: str, port: int, ssrc: int) -> tuple[str, int]

Connect to a Discord voice server.

PARAMETER DESCRIPTION
ip

The Discord voice server's IP.

TYPE: str

port

The Discord voice server's port.

TYPE: int

ssrc

Our assigned SSRC by Discord's voice gateway.

TYPE: int

RETURNS DESCRIPTION
tuple[str, int]

Our public, discovered IP address.

disconnect async

disconnect() -> None

Disconnect from Discord's voice server.

send async

send(data: bytes) -> None

Send a UDP packet to Discord's voice server.

PARAMETER DESCRIPTION
data

The UDP packet to send.

TYPE: bytes