Skip to content

API reference / @jsprismarine/raknet

@jsprismarine/raknet ​

Join the Discord Servernpm

Namespaces ​

Enumerations ​

BitFlags ​

Defined in: raknet/src/protocol/BitFlags.ts:14

The bits of a datagram's first byte, and the split bit of a frame's.

VALID marks a datagram of the reliability layer at all; ACK and NACK say which kind it is, and a datagram with neither carries frames. The low bits of a data datagram are hints for RakNet's congestion control: PACKET_PAIR, CONTINUOUS_SEND and NEEDS_B_AND_AS. The sliding window variant Bedrock uses ignores all three on receipt, so a client datagram tagged 0x84 or 0x8c decodes exactly like the 0x80 we send.

SPLIT lives in a frame header byte, not the datagram's, and happens to share its value with the packet pair bit; it is listed here because the frame codec always has.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/ReliabilityLayer.cpp#L150

Enumeration Members ​

ACK ​

ACK: 64

Defined in: raknet/src/protocol/BitFlags.ts:16

CONTINUOUS_SEND ​

CONTINUOUS_SEND: 8

Defined in: raknet/src/protocol/BitFlags.ts:21

The sender had more queued behind this datagram.

NACK ​

NACK: 32

Defined in: raknet/src/protocol/BitFlags.ts:17

NEEDS_B_AND_AS ​

NEEDS_B_AND_AS: 4

Defined in: raknet/src/protocol/BitFlags.ts:23

The sender is in slow start and would like bandwidth estimates in our acknowledgments.

SPLIT ​

SPLIT: 16

Defined in: raknet/src/protocol/BitFlags.ts:19

On a datagram: the second of a packet pair. On a frame: one fragment of a split message.

VALID ​

VALID: 128

Defined in: raknet/src/protocol/BitFlags.ts:15


FrameReliability ​

Defined in: raknet/src/protocol/FrameReliability.ts:2

Enumeration Members ​

RELIABLE ​

RELIABLE: 2

Defined in: raknet/src/protocol/FrameReliability.ts:5

RELIABLE_ORDERED ​

RELIABLE_ORDERED: 3

Defined in: raknet/src/protocol/FrameReliability.ts:6

RELIABLE_ORDERED_WITH_ACK_RECEIPT ​

RELIABLE_ORDERED_WITH_ACK_RECEIPT: 7

Defined in: raknet/src/protocol/FrameReliability.ts:10

RELIABLE_SEQUENCED ​

RELIABLE_SEQUENCED: 4

Defined in: raknet/src/protocol/FrameReliability.ts:7

RELIABLE_WITH_ACK_RECEIPT ​

RELIABLE_WITH_ACK_RECEIPT: 6

Defined in: raknet/src/protocol/FrameReliability.ts:9

UNRELIABLE ​

UNRELIABLE: 0

Defined in: raknet/src/protocol/FrameReliability.ts:3

UNRELIABLE_SEQUENCED ​

UNRELIABLE_SEQUENCED: 1

Defined in: raknet/src/protocol/FrameReliability.ts:4

UNRELIABLE_WITH_ACK_RECEIPT ​

UNRELIABLE_WITH_ACK_RECEIPT: 5

Defined in: raknet/src/protocol/FrameReliability.ts:8


MessageIdentifiers ​

Defined in: raknet/src/protocol/MessageIdentifiers.ts:2

Enumeration Members ​

ACKNOWLEDGE_PACKET ​

ACKNOWLEDGE_PACKET: 192

Defined in: raknet/src/protocol/MessageIdentifiers.ts:38

ADVERTISE_SYSTEM: 29

Defined in: raknet/src/protocol/MessageIdentifiers.ts:32

ALREADY_CONNECTED ​

ALREADY_CONNECTED: 18

Defined in: raknet/src/protocol/MessageIdentifiers.ts:21

CONNECTED_PING ​

CONNECTED_PING: 0

Defined in: raknet/src/protocol/MessageIdentifiers.ts:3

CONNECTED_PONG ​

CONNECTED_PONG: 3

Defined in: raknet/src/protocol/MessageIdentifiers.ts:6

CONNECTION_ATTEMPT_FAILED ​

CONNECTION_ATTEMPT_FAILED: 17

Defined in: raknet/src/protocol/MessageIdentifiers.ts:20

CONNECTION_BANNED ​

CONNECTION_BANNED: 23

Defined in: raknet/src/protocol/MessageIdentifiers.ts:26

CONNECTION_LOST ​

CONNECTION_LOST: 22

Defined in: raknet/src/protocol/MessageIdentifiers.ts:25

CONNECTION_REQUEST ​

CONNECTION_REQUEST: 9

Defined in: raknet/src/protocol/MessageIdentifiers.ts:12

CONNECTION_REQUEST_ACCEPTED ​

CONNECTION_REQUEST_ACCEPTED: 16

Defined in: raknet/src/protocol/MessageIdentifiers.ts:19

DETECT_LOST_CONNECTIONS ​

DETECT_LOST_CONNECTIONS: 4

Defined in: raknet/src/protocol/MessageIdentifiers.ts:7

DISCONNECTION_NOTIFICATION ​

DISCONNECTION_NOTIFICATION: 21

Defined in: raknet/src/protocol/MessageIdentifiers.ts:24

DOWNLOAD_PROGRESS ​

DOWNLOAD_PROGRESS: 30

Defined in: raknet/src/protocol/MessageIdentifiers.ts:33

INCOMPATIBLE_PROTOCOL_VERSION ​

INCOMPATIBLE_PROTOCOL_VERSION: 25

Defined in: raknet/src/protocol/MessageIdentifiers.ts:28

INVALID_PASSWORD ​

INVALID_PASSWORD: 24

Defined in: raknet/src/protocol/MessageIdentifiers.ts:27

IP_RECENTLY_CONNECTED ​

IP_RECENTLY_CONNECTED: 26

Defined in: raknet/src/protocol/MessageIdentifiers.ts:29

NACKNOWLEDGE_PACKET ​

NACKNOWLEDGE_PACKET: 160

Defined in: raknet/src/protocol/MessageIdentifiers.ts:39

NEW_INCOMING_CONNECTION ​

NEW_INCOMING_CONNECTION: 19

Defined in: raknet/src/protocol/MessageIdentifiers.ts:22

NO_FREE_INCOMING_CONNECTIONS ​

NO_FREE_INCOMING_CONNECTIONS: 20

Defined in: raknet/src/protocol/MessageIdentifiers.ts:23

OPEN_CONNECTION_REPLY_1 ​

OPEN_CONNECTION_REPLY_1: 6

Defined in: raknet/src/protocol/MessageIdentifiers.ts:9

OPEN_CONNECTION_REPLY_2 ​

OPEN_CONNECTION_REPLY_2: 8

Defined in: raknet/src/protocol/MessageIdentifiers.ts:11

OPEN_CONNECTION_REQUEST_1 ​

OPEN_CONNECTION_REQUEST_1: 5

Defined in: raknet/src/protocol/MessageIdentifiers.ts:8

OPEN_CONNECTION_REQUEST_2 ​

OPEN_CONNECTION_REQUEST_2: 7

Defined in: raknet/src/protocol/MessageIdentifiers.ts:10

OUR_SYSTEM_REQUIRES_SECURITY ​

OUR_SYSTEM_REQUIRES_SECURITY: 11

Defined in: raknet/src/protocol/MessageIdentifiers.ts:14

OUT_OF_BAND_INTERNAL ​

OUT_OF_BAND_INTERNAL: 13

Defined in: raknet/src/protocol/MessageIdentifiers.ts:16

PUBLIC_KEY_MISMATCH ​

PUBLIC_KEY_MISMATCH: 12

Defined in: raknet/src/protocol/MessageIdentifiers.ts:15

QUERY ​

QUERY: 254

Defined in: raknet/src/protocol/MessageIdentifiers.ts:40

REMOTE_CONNECTION_LOST ​

REMOTE_CONNECTION_LOST: 32

Defined in: raknet/src/protocol/MessageIdentifiers.ts:35

REMOTE_DISCONNECTION_NOTIFICATION ​

REMOTE_DISCONNECTION_NOTIFICATION: 31

Defined in: raknet/src/protocol/MessageIdentifiers.ts:34

REMOTE_NEW_INCOMING_CONNECTION ​

REMOTE_NEW_INCOMING_CONNECTION: 33

Defined in: raknet/src/protocol/MessageIdentifiers.ts:36

REMOTE_SYSTEM_REQUIRES_PUBLIC_KEY ​

REMOTE_SYSTEM_REQUIRES_PUBLIC_KEY: 10

Defined in: raknet/src/protocol/MessageIdentifiers.ts:13

SND_RECEIPT_ACKED ​

SND_RECEIPT_ACKED: 14

Defined in: raknet/src/protocol/MessageIdentifiers.ts:17

SND_RECEIPT_LOSS ​

SND_RECEIPT_LOSS: 15

Defined in: raknet/src/protocol/MessageIdentifiers.ts:18

TIMESTAMP ​

TIMESTAMP: 27

Defined in: raknet/src/protocol/MessageIdentifiers.ts:30

UNCONNECTED_PING ​

UNCONNECTED_PING: 1

Defined in: raknet/src/protocol/MessageIdentifiers.ts:4

UNCONNECTED_PING_OPEN_CONNECTIONS ​

UNCONNECTED_PING_OPEN_CONNECTIONS: 2

Defined in: raknet/src/protocol/MessageIdentifiers.ts:5

UNCONNECTED_PONG ​

UNCONNECTED_PONG: 28

Defined in: raknet/src/protocol/MessageIdentifiers.ts:31


RakNetPriority ​

Defined in: raknet/src/Session.ts:41

Enumeration Members ​

IMMEDIATE ​

IMMEDIATE: 1

Defined in: raknet/src/Session.ts:43

NORMAL ​

NORMAL: 0

Defined in: raknet/src/Session.ts:42


RakNetRole ​

Defined in: raknet/src/Session.ts:64

Which side of the connection this session is.

The reliability layer is symmetric and does not consult this; only the handshake does. The two roles exchange disjoint messages - a server answers CONNECTION_REQUEST and waits for NEW_INCOMING_CONNECTION, a client sends CONNECTION_REQUEST and answers CONNECTION_REQUEST_ACCEPTED - so the branch could in principle be keyed on the message id alone. It is not, deliberately: that would let a peer talk a listening server through the client half of the handshake and reach CONNECTED without ever sending NEW_INCOMING_CONNECTION.

Enumeration Members ​

CLIENT ​

CLIENT: 1

Defined in: raknet/src/Session.ts:66

SERVER ​

SERVER: 0

Defined in: raknet/src/Session.ts:65


SessionStatus ​

Defined in: raknet/src/Session.ts:46

Enumeration Members ​

CONNECTED ​

CONNECTED: 1

Defined in: raknet/src/Session.ts:48

CONNECTING ​

CONNECTING: 0

Defined in: raknet/src/Session.ts:47

DISCONNECTED ​

DISCONNECTED: 3

Defined in: raknet/src/Session.ts:50

DISCONNECTING ​

DISCONNECTING: 2

Defined in: raknet/src/Session.ts:49

Classes ​

Interfaces ​

ClientSocketOptions ​

Defined in: raknet/src/ClientSocket.ts:85

Requested UDP socket buffer sizes. The operating system may grant less.

Extends ​

Properties ​

bindAddress? ​

readonly optional bindAddress?: string

Defined in: raknet/src/ClientSocket.ts:89

Local address to bind. The ephemeral port is always chosen by the OS.

recvBufferSize? ​

readonly optional recvBufferSize?: number

Defined in: raknet/src/SocketBuffers.ts:7

Receive buffer size in bytes. Defaults to 4 MiB.

Inherited from ​

SocketBufferOptions.recvBufferSize

sendBufferSize? ​

readonly optional sendBufferSize?: number

Defined in: raknet/src/SocketBuffers.ts:9

Send buffer size in bytes. Defaults to 4 MiB.

Inherited from ​

SocketBufferOptions.sendBufferSize

timeoutMs? ​

readonly optional timeoutMs?: number

Defined in: raknet/src/ClientSocket.ts:87

Overall budget for ClientSocket.connect.


DatagramRings ​

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

The shared memory of a pair of datagram rings, as it crosses to a worker thread.

Extended by ​

Properties ​

inbound ​

readonly inbound: SharedArrayBuffer

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

Written by the port's owner, read by RakNet.

outbound ​

readonly outbound: SharedArrayBuffer

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

Written by RakNet, read by the port's owner.


DatagramSource ​

Defined in: raknet/src/DatagramSource.ts:17

Where a ServerSocket reads its datagrams and sends its own: a UDP socket of its own, or a port another component owns and shares, such as the native networking library's port that NetherNet also serves. RakNet's protocol code is the same over either.

Methods ​

close() ​

close(): void

Defined in: raknet/src/DatagramSource.ts:30

Stops delivering and sending.

Returns ​

void

send() ​

send(buffers, port, address): void

Defined in: raknet/src/DatagramSource.ts:28

Sends one datagram, made of these buffers in order. Nothing happens once the source closed.

Parameters ​
buffers ​

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

port ​

number

address ​

string

Returns ​

void

start() ​

start(address, port, listener): Promise<number>

Defined in: raknet/src/DatagramSource.ts:26

Starts delivering datagrams.

Parameters ​
address ​

string

The address to bind, IPv4 or IPv6.

port ​

number

The port to bind; 0 lets the operating system choose.

listener ​

DatagramListener

Receives every datagram.

Returns ​

Promise<number>

The port clients reach.

Throws ​

When the source cannot start, such as a port another program holds.


EffectiveSocketBuffers ​

Defined in: raknet/src/SocketBuffers.ts:13

Buffer sizes the operating system reports after applying its limits.

Properties ​

recvBufferSize ​

readonly recvBufferSize: number

Defined in: raknet/src/SocketBuffers.ts:14

sendBufferSize ​

readonly sendBufferSize: number

Defined in: raknet/src/SocketBuffers.ts:15


LoopbackEndpoint ​

Defined in: raknet/src/LoopbackSocket.ts:60

One end of a loopback pair: a RakNetPeer whose "socket" is the other end.

Everything above this - framing, ordering, acknowledgment, reassembly, the connected handshake - is the ordinary RakNetSession, unmodified. That is the entire point, and it is worth being explicit about the alternative that was not taken: handing frames across directly, skipping the reliability layer, would have meant reimplementing Session.handlePacket - the disconnect, ping and state-machine dispatch that decides what becomes an encapsulated event. Single player would then run similar code to multiplayer rather than the same code, and the two would drift exactly where it is hardest to notice.

What is skipped is the offline exchange, which exists only to discover a path MTU and a guid across a network that is not here.

Extends ​

  • EventEmitter

Implements ​

Properties ​

localAddress ​

readonly localAddress: InetAddress

Defined in: raknet/src/LoopbackSocket.ts:78

Methods ​

getAddress() ​

getAddress(): InetAddress

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

Returns ​

InetAddress

getLogger() ​

getLogger(): Logger

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

Returns ​

Logger

Implementation of ​

RakNetPeer.getLogger

getSession() ​

getSession(): RakNetSession | null

Defined in: raknet/src/LoopbackSocket.ts:102

Returns ​

RakNetSession | null

getSessions() ​

getSessions(): RakNetSession[]

Defined in: raknet/src/LoopbackSocket.ts:107

Present so a caller written against ServerSocket finds what it expects.

Returns ​

RakNetSession[]

removeSession() ​

removeSession(session, reason?): void

Defined in: raknet/src/LoopbackSocket.ts:141

The session has finished disconnecting and should be forgotten. Called exactly once per session, from Session.disconnect.

Parameters ​
session ​

RakNetSession

reason? ​

string

Returns ​

void

Implementation of ​

RakNetPeer.removeSession

sendBuffer() ​

sendBuffer(buffer, _rinfo): void

Defined in: raknet/src/LoopbackSocket.ts:124

Parameters ​
buffer ​

Buffer

_rinfo ​

RemoteInfo

Returns ​

void

sendPacket() ​

sendPacket(packet, _rinfo): void

Defined in: raknet/src/LoopbackSocket.ts:119

Encodes and sends a packet to rinfo. Sessions never touch a socket directly - a closed or unbound one has to be the peer's problem, since only the peer knows.

Parameters ​
packet ​

Packet

_rinfo ​

RemoteInfo

Returns ​

void

Implementation of ​

RakNetPeer.sendPacket


LoopbackOptions ​

Defined in: raknet/src/LoopbackSocket.ts:37

Properties ​

clientAddress? ​

readonly optional clientAddress?: string

Defined in: raknet/src/LoopbackSocket.ts:41

clientPort? ​

readonly optional clientPort?: number

Defined in: raknet/src/LoopbackSocket.ts:42

serverAddress? ​

readonly optional serverAddress?: string

Defined in: raknet/src/LoopbackSocket.ts:39

What each side reports as the other's address. Cosmetic - nothing routes on it.

serverPort? ​

readonly optional serverPort?: number

Defined in: raknet/src/LoopbackSocket.ts:40


PingResult ​

Defined in: raknet/src/ClientSocket.ts:77

Properties ​

rtt ​

readonly rtt: number

Defined in: raknet/src/ClientSocket.ts:82

Round trip in milliseconds, on the monotonic clock.

serverGuid ​

readonly serverGuid: bigint

Defined in: raknet/src/ClientSocket.ts:80

serverName ​

readonly serverName: string

Defined in: raknet/src/ClientSocket.ts:79

The raw MOTD line, e.g. MCPE;Server;748;1.21.40;0;10;….


RakNetListenerLike ​

Defined in: raknet/src/RakNetPeer.ts:55

The server-facing RakNet API shared by the socket and worker-backed implementations.

Extends ​

Properties ​

serverName ​

readonly serverName: ServerName

Defined in: raknet/src/RakNetPeer.ts:56

Methods ​

allowIncomingConnections() ​

allowIncomingConnections(): boolean

Defined in: raknet/src/RakNetPeer.ts:60

Returns ​

boolean

emit() ​

emit(event, ...args): boolean

Defined in: raknet/src/RakNetPeer.ts:45

Parameters ​
event ​

string | symbol

args ​

...any[]

Returns ​

boolean

Inherited from ​

RakNetPeer.emit

getLogger() ​

getLogger(): Logger

Defined in: raknet/src/RakNetPeer.ts:37

Returns ​

Logger

Inherited from ​

RakNetPeer.getLogger

getMaxConnections() ​

getMaxConnections(): number

Defined in: raknet/src/RakNetPeer.ts:61

Returns ​

number

getServerGuid() ​

getServerGuid(): bigint

Defined in: raknet/src/RakNetPeer.ts:66

Returns ​

bigint

getSessionByAddress() ​

getSessionByAddress(rinfo): RakNetSession | null

Defined in: raknet/src/RakNetPeer.ts:64

Parameters ​
rinfo ​

RemoteInfo

Returns ​

RakNetSession | null

getSessionByGUID() ​

getSessionByGUID(guid): RakNetSession | null

Defined in: raknet/src/RakNetPeer.ts:65

Parameters ​
guid ​

bigint

Returns ​

RakNetSession | null

getSessions() ​

getSessions(): RakNetSession[]

Defined in: raknet/src/RakNetPeer.ts:63

Returns ​

RakNetSession[]

kill() ​

kill(): void

Defined in: raknet/src/RakNetPeer.ts:59

Returns ​

void

on() ​
Call Signature ​

on(event, listener): this

Defined in: raknet/src/RakNetPeer.ts:68

Parameters ​
event ​

"openConnection"

listener ​

(session) => void

Returns ​

this

Call Signature ​

on(event, listener): this

Defined in: raknet/src/RakNetPeer.ts:69

Parameters ​
event ​

"closeConnection"

listener ​

(address, reason) => void

Returns ​

this

Call Signature ​

on(event, listener): this

Defined in: raknet/src/RakNetPeer.ts:70

Parameters ​
event ​

"encapsulated"

listener ​

(frame, address) => void

Returns ​

this

Call Signature ​

on(event, listener): this

Defined in: raknet/src/RakNetPeer.ts:71

Parameters ​
event ​

"raw"

listener ​

(buffer, address) => void

Returns ​

this

Call Signature ​

on(event, listener): this

Defined in: raknet/src/RakNetPeer.ts:73

The socket is bound, on the port given; 0 asked for any port, and this is the one granted.

Parameters ​
event ​

"listening"

listener ​

(port) => void

Returns ​

this

Call Signature ​

on(event, listener): this

Defined in: raknet/src/RakNetPeer.ts:75

The socket could not bind, so the listener has stopped.

Parameters ​
event ​

"error"

listener ​

(error) => void

Returns ​

this

removeSession() ​

removeSession(session, reason?): void

Defined in: raknet/src/RakNetPeer.ts:51

The session has finished disconnecting and should be forgotten. Called exactly once per session, from Session.disconnect.

Parameters ​
session ​

RakNetSession

reason? ​

string

Returns ​

void

Inherited from ​

RakNetPeer.removeSession

sendBuffer() ​

sendBuffer(buffer, rinfo): void

Defined in: raknet/src/RakNetPeer.ts:67

Parameters ​
buffer ​

Buffer

rinfo ​

RemoteInfo

Returns ​

void

sendPacket() ​

sendPacket(packet, rinfo): void

Defined in: raknet/src/RakNetPeer.ts:43

Encodes and sends a packet to rinfo. Sessions never touch a socket directly - a closed or unbound one has to be the peer's problem, since only the peer knows.

Parameters ​
packet ​

Packet

rinfo ​

RemoteInfo

Returns ​

void

Inherited from ​

RakNetPeer.sendPacket

setMaxConnections() ​

setMaxConnections(allowed): void

Defined in: raknet/src/RakNetPeer.ts:62

Parameters ​
allowed ​

number

Returns ​

void

start() ​

start(address, port): void

Defined in: raknet/src/RakNetPeer.ts:58

Parameters ​
address ​

string

port ​

number

Returns ​

void


RakNetPeer ​

Defined in: raknet/src/RakNetPeer.ts:36

Everything a Session needs from whatever owns its socket.

The reliability layer is written entirely in terms of "the peer that carries my datagrams" and never asks whether that peer is accepting connections or making one. That distinction lives in Session's handshake branch and nowhere else, so the same ACK/NACK, ordering, fragmentation and retransmission code serves both roles.

The surface is four members wide, which is the whole point: @jsprismarine/client used to drive a session by passing itself as this as any in place of a ServerSocket, because there was no smaller contract to implement. There is now.

Extended by ​

Methods ​

emit() ​

emit(event, ...args): boolean

Defined in: raknet/src/RakNetPeer.ts:45

Parameters ​
event ​

string | symbol

args ​

...any[]

Returns ​

boolean

getLogger() ​

getLogger(): Logger

Defined in: raknet/src/RakNetPeer.ts:37

Returns ​

Logger

removeSession() ​

removeSession(session, reason?): void

Defined in: raknet/src/RakNetPeer.ts:51

The session has finished disconnecting and should be forgotten. Called exactly once per session, from Session.disconnect.

Parameters ​
session ​

RakNetSession

reason? ​

string

Returns ​

void

sendPacket() ​

sendPacket(packet, rinfo): void

Defined in: raknet/src/RakNetPeer.ts:43

Encodes and sends a packet to rinfo. Sessions never touch a socket directly - a closed or unbound one has to be the peer's problem, since only the peer knows.

Parameters ​
packet ​

Packet

rinfo ​

RemoteInfo

Returns ​

void


ServerNameSnapshot ​

Defined in: raknet/src/utils/ServerName.ts:16

The values a network worker needs to reproduce the server-list pong.

Properties ​

gamemode ​

readonly gamemode: string

Defined in: raknet/src/utils/ServerName.ts:23

maxPlayers ​

readonly maxPlayers: number

Defined in: raknet/src/utils/ServerName.ts:22

motd ​

readonly motd: string

Defined in: raknet/src/utils/ServerName.ts:17

name ​

readonly name: string

Defined in: raknet/src/utils/ServerName.ts:18

onlinePlayers ​

readonly onlinePlayers: number

Defined in: raknet/src/utils/ServerName.ts:21

port ​

readonly port: number

Defined in: raknet/src/utils/ServerName.ts:25

portV6 ​

readonly portV6: number

Defined in: raknet/src/utils/ServerName.ts:26

protocol ​

readonly protocol: number

Defined in: raknet/src/utils/ServerName.ts:19

serverId ​

readonly serverId: string

Defined in: raknet/src/utils/ServerName.ts:24

version ​

readonly version: string

Defined in: raknet/src/utils/ServerName.ts:20


ServerNameSource ​

Defined in: raknet/src/utils/ServerName.ts:10

The server state a ServerName reads when it is created.

Methods ​

getConfig() ​

getConfig(): object

Defined in: raknet/src/utils/ServerName.ts:12

Returns the configuration the advertised MOTD, gamemode, and player cap come from.

Returns ​

object

getGamemode() ​

getGamemode(): string

Returns ​

string

getMaxPlayers() ​

getMaxPlayers(): number

Returns ​

number

getMotd() ​

getMotd(): string

Returns ​

string


ServerProtocolInfo ​

Defined in: raknet/src/utils/ServerName.ts:2

The protocol version and Minecraft releases a server supports.

Properties ​

minecraftVersions ​

readonly minecraftVersions: readonly string[]

Defined in: raknet/src/utils/ServerName.ts:6

Supported Minecraft releases in ascending order; the last is advertised.

protocolVersion ​

readonly protocolVersion: number

Defined in: raknet/src/utils/ServerName.ts:4

The newest protocol version the server accepts.


SharedPortRings ​

Defined in: raknet/src/WorkerServerSocket.ts:58

A port the native networking library shares with this listener, and how its rings are attached.

Properties ​

attach ​

readonly attach: AttachRings

Defined in: raknet/src/WorkerServerSocket.ts:64

Attaches the rings once the worker can be woken; see AttachRings.

family ​

readonly family: 4 | 6

Defined in: raknet/src/WorkerServerSocket.ts:60

port ​

readonly port: number

Defined in: raknet/src/WorkerServerSocket.ts:62

The port clients reach.

rings ​

readonly rings: DatagramRings

Defined in: raknet/src/WorkerServerSocket.ts:59


SocketBufferOptions ​

Defined in: raknet/src/SocketBuffers.ts:5

Requested UDP socket buffer sizes. The operating system may grant less.

Extended by ​

Properties ​

recvBufferSize? ​

readonly optional recvBufferSize?: number

Defined in: raknet/src/SocketBuffers.ts:7

Receive buffer size in bytes. Defaults to 4 MiB.

sendBufferSize? ​

readonly optional sendBufferSize?: number

Defined in: raknet/src/SocketBuffers.ts:9

Send buffer size in bytes. Defaults to 4 MiB.


WorkerSharedPort ​

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

A shared port as a worker thread receives it: the rings, the address family and the port.

Extends ​

Properties ​

family ​

readonly family: 4 | 6

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

inbound ​

readonly inbound: SharedArrayBuffer

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

Written by the port's owner, read by RakNet.

Inherited from ​

DatagramRings.inbound

outbound ​

readonly outbound: SharedArrayBuffer

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

Written by RakNet, read by the port's owner.

Inherited from ​

DatagramRings.outbound

port ​

readonly port: number

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

Type Aliases ​

AttachRings ​

AttachRings = (wakePort) => number | Promise<number>

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

Hands the rings to the port's owner once RakNet can be woken.

Parameters ​

wakePort ​

number

The loopback UDP port RakNet listens on for a wake after inbound writes.

Returns ​

number | Promise<number>

The loopback UDP port the owner listens on for a wake after outbound writes.


DatagramListener ​

DatagramListener = (datagram, from) => void

Defined in: raknet/src/DatagramSource.ts:10

Receives each datagram a source delivers, with where it came from.

Parameters ​

datagram ​

Buffer

from ​

RemoteInfo

Returns ​

void


Logger ​

Logger = object

Defined in: raknet/src/RakNetPeer.ts:15

The logging surface RakNet uses.

Structural rather than an import of @jsprismarine/logger: this package deliberately depends on nothing but binaryutils, and anything satisfying these six methods - the real logger, a test double, a console - can drive it.

Properties ​

debug ​

debug: (...message) => void

Defined in: raknet/src/RakNetPeer.ts:20

Parameters ​
message ​

...string[]

Returns ​

void

error ​

error: (...message) => void

Defined in: raknet/src/RakNetPeer.ts:18

Parameters ​
message ​

...string[]

Returns ​

void

info ​

info: (...message) => void

Defined in: raknet/src/RakNetPeer.ts:16

Parameters ​
message ​

...string[]

Returns ​

void

silly ​

silly: (...message) => void

Defined in: raknet/src/RakNetPeer.ts:21

Parameters ​
message ​

...string[]

Returns ​

void

verbose ​

verbose: (...message) => void

Defined in: raknet/src/RakNetPeer.ts:19

Parameters ​
message ​

...string[]

Returns ​

void

warn ​

warn: (...message) => void

Defined in: raknet/src/RakNetPeer.ts:17

Parameters ​
message ​

...string[]

Returns ​

void

Variables ​

CONNECTED_PING_INTERVAL_MS ​

const CONNECTED_PING_INTERVAL_MS: 2500 = 2_500

Defined in: raknet/src/Constants.ts:96

How often a connected client pings.

Comfortably under half SESSION_TIMEOUT_MS, so a couple of lost pings still leave the peer something to see before it times us out. A Minecraft session is rarely idle in both directions, but a client that is merely standing still is - and it is exactly the bot harness, which stands still by the hundred, that would find out.


CONNECTION_ATTEMPT_INTERVAL_MS ​

const CONNECTION_ATTEMPT_INTERVAL_MS: 500 = 500

Defined in: raknet/src/Constants.ts:85

How often an outgoing connection repeats an offline request that went unanswered, and how long it keeps trying before giving up. Both halves of the offline exchange are unreliable by construction - there is no session yet to retransmit them.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/RakPeer.cpp#L488 (timeBetweenSendConnectionAttemptsMS)


CONNECTION_ATTEMPT_TIMEOUT_MS ​

const CONNECTION_ATTEMPT_TIMEOUT_MS: 10000 = 10_000

Defined in: raknet/src/Constants.ts:86


DEFAULT_DATAGRAM_RING_CAPACITY ​

const DEFAULT_DATAGRAM_RING_CAPACITY: number

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

Each ring's capacity unless the caller picks one: room for a burst at full speed.


DISCONNECT_LINGER_TIMEOUT_MS ​

const DISCONNECT_LINGER_TIMEOUT_MS: 3000 = 3_000

Defined in: raknet/src/Constants.ts:77

How long a session hangs on after saying goodbye, waiting for the peer to acknowledge it.

Only a backstop: the ordinary case ends one round trip after the notification goes out, and the peer's own goodbye ends on the next tick. This bounds the case where the peer has already stopped listening, and is comfortably under SESSION_TIMEOUT_MS so a session on its way out can never outlive a live one.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/RakPeer.cpp#L5875


LOOPBACK_MTU_SIZE ​

const LOOPBACK_MTU_SIZE: number

Defined in: raknet/src/LoopbackSocket.ts:35

The MTU a loopback pair runs at.

Not "as large as possible": the frame length field above caps a fragment at 8191 bytes, and Session.sendFrame derives its fragment size as mtu - UDP_HEADER_SIZE - DATAGRAM_HEADER_BYTE_LENGTH - MAX_FRAME_BYTE_LENGTH, so 8 KiB lands at 8163 and stays inside it. That is still five and a half times the 1464 a real connection negotiates, which is where the win is: a chunk batch that fragments seventeen ways on the wire fragments three ways here.


MAXIMUM_NUMBER_OF_INTERNAL_IDS ​

const MAXIMUM_NUMBER_OF_INTERNAL_IDS: 20 = 20

Defined in: raknet/src/Constants.ts:129

How many internal addresses follow the peer's own in ConnectionRequestAccepted and NewIncomingConnection. RakNet fixes it at compile time and both ends must agree on it: the public archive builds with 10, Mojang's fork with 20.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/RakNetDefines.h#L76 (MAXIMUM_NUMBER_OF_INTERNAL_IDS)


MAX_CHANNELS ​

const MAX_CHANNELS: 32 = 32

Defined in: raknet/src/Constants.ts:8


MAX_CONCURRENT_SPLITS ​

const MAX_CONCURRENT_SPLITS: 64 = 64

Defined in: raknet/src/Constants.ts:48

How many split messages a peer may have in flight before we stop accepting new ones.


MAX_DATAGRAM_HISTORY ​

const MAX_DATAGRAM_HISTORY: 512 = 512

Defined in: raknet/src/Constants.ts:14

Upper bound on the sent-datagram history kept per session for ACK/NACK resolution.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/RakNetDefines.h#L105


MAX_FRAME_CONTENT_BYTE_LENGTH ​

const MAX_FRAME_CONTENT_BYTE_LENGTH: number

Defined in: raknet/src/LoopbackSocket.ts:23

The largest content a single frame can carry.

Frame.toBinary writes the content length in bits into an unsigned 16 bit field, so anything past 8191 bytes silently wraps that field and the receiver reads a different message than the one that was sent. On the network path MAX_MTU_SIZE keeps this unreachable; in memory there is no path MTU to hide behind, so it has to be respected deliberately.


MAX_MTU_SIZE ​

const MAX_MTU_SIZE: 1492 = 1492

Defined in: raknet/src/Constants.ts:136


MAX_NACK_WINDOW ​

const MAX_NACK_WINDOW: 512 = 512

Defined in: raknet/src/Constants.ts:28

How far back we chase holes in the incoming datagram sequence. A peer can name an arbitrarily distant sequence number, and the gap between it and the last one we saw must never be walked one by one without a bound.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/CCRakNetSlidingWindow.cpp#L146


MAX_ORDERING_QUEUE_SIZE ​

const MAX_ORDERING_QUEUE_SIZE: 2048 = 2048

Defined in: raknet/src/Constants.ts:45

How many frames may sit buffered per ordering channel waiting for a hole to be filled.


MAX_RECEIVE_WINDOW ​

const MAX_RECEIVE_WINDOW: 4096 = 4096

Defined in: raknet/src/Constants.ts:42

How many reliable messages may be outstanding ahead of the oldest one we are still waiting for. Bounds the memory the duplicate-detection window can be made to hold. RakNet gives up past 1,000,000; we are far stricter because we keep the window in a Set.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/ReliabilityLayer.cpp#L1003


MAX_SKIPPED_DATAGRAMS ​

const MAX_SKIPPED_DATAGRAMS: 50000 = 50_000

Defined in: raknet/src/Constants.ts:34

A gap larger than this in the incoming datagram sequence is not loss, it is garbage.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/CCRakNetSlidingWindow.cpp#L149


MAX_SPLIT_PACKET_COUNT ​

const MAX_SPLIT_PACKET_COUNT: 2048 = 2048

Defined in: raknet/src/Constants.ts:51

Upper bound on the fragment count a single split message may declare.


MAX_TRIAD_VALUE ​

const MAX_TRIAD_VALUE: 16777215 = 0xffffff

Defined in: raknet/src/Constants.ts:17

Sequence numbers, reliable indices and ordering indices are 24 bit on the wire.


MINECRAFT_PROTOCOL_VERSION ​

const MINECRAFT_PROTOCOL_VERSION: 11 = RAKNET_PROTOCOL_VERSION

Defined in: raknet/src/Constants.ts:120

Deprecated ​

Use RAKNET_PROTOCOL_VERSION; this is the RakNet version, not Minecraft's.


MIN_DATAGRAM_BYTE_LENGTH ​

const MIN_DATAGRAM_BYTE_LENGTH: 2 = 2

Defined in: raknet/src/Constants.ts:107

The largest datagram that cannot possibly mean anything, and so is dropped unread.

The shortest acknowledgment is seven bytes (id, record count, flag, triad) and the shortest data datagram eight, so two bytes is comfortably below anything legitimate. RakNet draws the line in the same place, before its reliability layer rather than inside the decoder.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/RakPeer.cpp#L4582


MIN_MTU_SIZE ​

const MIN_MTU_SIZE: 400 = 400

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


OFFLINE_MESSAGE_DATA_ID ​

const OFFLINE_MESSAGE_DATA_ID: Buffer

Defined in: raknet/src/Constants.ts:131

RakNet's OFFLINE_MESSAGE_DATA_ID, the 16 byte magic every offline packet carries.


RAKNET_PROTOCOL_VERSION ​

const RAKNET_PROTOCOL_VERSION: 11 = 11

Defined in: raknet/src/Constants.ts:118

The RakNet protocol version Bedrock speaks, carried in OpenConnectionRequest1 and answered with IncompatibleProtocolVersion when it differs. This is RakNet's own version byte (Mojang's fork is at 11; the public archive is at 6), not Minecraft's network protocol, which the game layer negotiates after the connection is up. It is a property of the client build, so there is no setter: a server speaking any other value could talk to no Bedrock client.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/RakNetVersion.h


RAKNET_TICK_INTERVAL_MS ​

const RAKNET_TICK_INTERVAL_MS: 10 = 10

Defined in: raknet/src/Constants.ts:6

How often a session is updated, in milliseconds. RakNet's own Startup contract documents this argument as a millisecond sleep and recommends 10.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/RakPeer.cpp#L360


RING_DATAGRAM_HEADER_BYTES ​

const RING_DATAGRAM_HEADER_BYTES: 20 = 20

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

The bytes before each datagram in a ring: family (4 or 6), reserved, port (LE), 16 address bytes.


RTO_ADDITIONAL_VARIANCE_MS ​

const RTO_ADDITIONAL_VARIANCE_MS: 30 = 30

Defined in: raknet/src/Constants.ts:63


RTO_MAX_MS ​

const RTO_MAX_MS: 2000 = 2000

Defined in: raknet/src/Constants.ts:62

Retransmission timeout bounds, in milliseconds. RTO = 2 * estimatedRTT + 4 * deviationRTT + variance, capped at the maximum, and equal to the maximum until the first RTT sample lands.

See ​

https://github.com/facebookarchive/RakNet/blob/master/Source/CCRakNetSlidingWindow.cpp#L288


SESSION_TIMEOUT_MS ​

const SESSION_TIMEOUT_MS: 10000 = 10_000

Defined in: raknet/src/Constants.ts:66

How long a session may go without any incoming traffic before it is dropped.


SPLIT_PACKET_TIMEOUT_MS ​

const SPLIT_PACKET_TIMEOUT_MS: 10000 = 10_000

Defined in: raknet/src/Constants.ts:54

An incomplete reassembly older than this is abandoned.


TRIAD_RANGE ​

const TRIAD_RANGE: number

Defined in: raknet/src/Constants.ts:20

One past the largest triad, i.e. the modulus every 24 bit counter wraps at.


UDP_HEADER_SIZE ​

const UDP_HEADER_SIZE: 28 = 28

Defined in: raknet/src/Constants.ts:122

The IPv4 and UDP headers a datagram pays for on the wire, which the MTU includes.

Functions ​

allocateDatagramRings() ​

allocateDatagramRings(capacity?): DatagramRings

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

Allocates the shared memory of a pair of rings in the layout SharedByteRing has.

Parameters ​

capacity? ​

number = DEFAULT_DATAGRAM_RING_CAPACITY

Each ring's capacity, a power of two.

Returns ​

DatagramRings

The memory.


configureSocketBuffers() ​

configureSocketBuffers(socket, logger, options?, context?): EffectiveSocketBuffers

Defined in: raknet/src/SocketBuffers.ts:34

Configures both UDP buffers after bind and reports the sizes the operating system grants. A kernel limit may clamp a request without throwing, so the getters are the useful result.

Parameters ​

socket ​

Pick<Dgram.Socket, "setRecvBufferSize" | "getRecvBufferSize" | "setSendBufferSize" | "getSendBufferSize">

logger ​

Logger

options? ​

SocketBufferOptions = {}

context? ​

string = 'RakNet/SocketBuffers'

Returns ​

EffectiveSocketBuffers


validateSocketBufferOptions() ​

validateSocketBufferOptions(options): void

Defined in: raknet/src/SocketBuffers.ts:19

Rejects invalid requests before a wrapper's asynchronous bind callback runs.

Parameters ​

options ​

SocketBufferOptions

Returns ​

void

References ​

ConnectionPriority ​

Renames and re-exports RakNetPriority


ServerSocket ​

Renames and re-exports RakNetListener


Session ​

Renames and re-exports RakNetSession