Skip to content

API reference / @jsprismarine/raknet / RingDatagramSource

Class: RingDatagramSource ​

Defined in: raknet/src/RingDatagramSource.ts:100

A port another component owns and shares with RakNet, reached through two rings in shared memory: the owner writes each RakNet datagram it receives into the inbound ring and RakNet writes each one it sends into the outbound ring, with a one-byte UDP datagram on the loopback interface to wake the other side, only when that side was idle. A burst costs one wake.

@jsprismarine/native-network's shared port is the owner the server uses; this package knows only the ring layout.

Implements ​

Constructors ​

Constructor ​

new RingDatagramSource(rings, family, sharedPort, attach): RingDatagramSource

Defined in: raknet/src/RingDatagramSource.ts:123

Parameters ​

rings ​

DatagramRings

The rings' shared memory.

family ​

4 | 6

The address family of the datagrams this source carries.

sharedPort ​

number

The port the owner serves, which clients reach.

attach ​

AttachRings

Hands the rings to the owner; see AttachRings.

Returns ​

RingDatagramSource

Properties ​

dropped ​

dropped: number = 0

Defined in: raknet/src/RingDatagramSource.ts:115

Datagrams dropped because the outbound ring was full.


received ​

received: number = 0

Defined in: raknet/src/RingDatagramSource.ts:111

Datagrams delivered to RakNet.


sent ​

sent: number = 0

Defined in: raknet/src/RingDatagramSource.ts:113

Datagrams written to the outbound ring.


wakes ​

wakes: number = 0

Defined in: raknet/src/RingDatagramSource.ts:109

Wakes received for inbound batches.

Methods ​

close() ​

close(): void

Defined in: raknet/src/RingDatagramSource.ts:177

Closes the wake socket; the rings belong to whoever allocated them.

Returns ​

void

Implementation of ​

DatagramSource.close


send() ​

send(buffers, port, address): void

Defined in: raknet/src/RingDatagramSource.ts:161

Writes the datagram to the outbound ring, and wakes the owner if it was idle.

Parameters ​

buffers ​

Buffer<ArrayBufferLike> | readonly Buffer<ArrayBufferLike>[]

port ​

number

address ​

string

Returns ​

void

Implementation of ​

DatagramSource.send


start() ​

start(_address, _port, listener): Promise<number>

Defined in: raknet/src/RingDatagramSource.ts:137

Binds the wake socket and attaches the rings; the address and port are the owner's.

Parameters ​

_address ​

string

_port ​

number

listener ​

DatagramListener

Returns ​

Promise<number>

The shared port.

Implementation of ​

DatagramSource.start