Skip to content

API reference / @jsprismarine/prismarine / modules/network

modules/network ​

Classes ​

Interfaces ​

Networking ​

Defined in: packages/prismarine/src/modules/network.ts:79

What the prismarine:network token resolves to: the server's network front door. The listener binds when Networking.start is called — the bind address and port arrive with Server.bootstrap, after the kernel has started — and stays up across a Server.reload; only Networking.kill takes it down.

Methods ​

admitInputs() ​

admitInputs(budget?): number

Defined in: packages/prismarine/src/modules/network.ts:137

The input step: applies the input-lane packets and player removals held since the last one, in arrival order. A no-op before Networking.start.

Parameters ​
budget? ​

number

The most inputs to apply; the rest wait for the next step, in order.

Returns ​

number

How many inputs were applied.

getJavaPort() ​

getJavaPort(): number | undefined

Defined in: packages/prismarine/src/modules/network.ts:126

The TCP port Java Edition clients connect to, which is the system's pick when java-port is 0.

Returns ​

number | undefined

The port, or undefined while java-enabled is off or before Networking.start.

getListener() ​

getListener(): RakNetListenerLike | undefined

Defined in: packages/prismarine/src/modules/network.ts:105

The RakNet listener, for what the transport seam does not cover: the query protocol's replies go out through its socket.

Returns ​

RakNetListenerLike | undefined

The listener, or undefined before Networking.start or with RakNet off.

getServerName() ​

getServerName(): ServerName | undefined

Defined in: packages/prismarine/src/modules/network.ts:112

RakNet's server name, which encodes the unconnected pong from the getServerStatus and the ports RakNet bound.

Returns ​

ServerName | undefined

The server name, or undefined before Networking.start.

getServerStatus() ​

getServerStatus(): ServerStatus

Defined in: packages/prismarine/src/modules/network.ts:119

What every transport advertises about the server: MOTD, version and player counts. It exists before Networking.start, so a change made earlier shows once the transports listen.

Returns ​

ServerStatus

holdIntent() ​

holdIntent(session, intent): Promise<void>

Defined in: packages/prismarine/src/modules/network.ts:147

Runs an intent the server makes on a player's behalf as the player's client's own: an input intent is held under the player's connection, behind the inputs the client sent, for the next input step. Nothing runs before Networking.start.

Parameters ​
session ​

PlayerSession

The player's session.

intent ​

Intent<keyof IntentPayloads>

The intent.

Returns ​

Promise<void>

Settles once the intent was applied.

isInboundSettled() ​

isInboundSettled(): boolean

Defined in: packages/prismarine/src/modules/network.ts:153

Whether every frame received so far has been handled, or waits behind an input held for the next input step. True before Networking.start.

Returns ​

boolean

kill() ​

kill(): void

Defined in: packages/prismarine/src/modules/network.ts:98

Closes every transport, dropping every session with them. A no-op before Networking.start, so an early shutdown has nothing to do here.

Returns ​

void

pollInbound() ​

pollInbound(): number

Defined in: packages/prismarine/src/modules/network.ts:129

Hands worker-delivered network records to the game thread at the end of a tick.

Returns ​

number

replayInboundRecord()? ​

optional replayInboundRecord(record, tickOffset?): Promise<void>

Defined in: packages/prismarine/src/modules/network.ts:92

Replays one accepted packet through the connected session's handler path.

Parameters ​
record ​

InboundPacketRecord

tickOffset? ​

number

Returns ​

Promise<void>

start() ​

start(address, port): Promise<void>

Defined in: packages/prismarine/src/modules/network.ts:89

Binds every enabled transport and wires inbound traffic to the packet dispatcher, and resolves once every transport listens.

Parameters ​
address ​

string

The address to bind.

port ​

number

The port to bind.

Returns ​

Promise<void>

Throws ​

When the config enables no transport, so no client could connect, or when an enabled transport cannot listen. The error names the transport, the port and the cause, and every transport that did start is closed again.

Functions ​

networkModule() ​

networkModule(networking): Module

Defined in: packages/prismarine/src/modules/network.ts:932

Provides the Networking service as prismarine:network. The module neither starts nor stops the listener: the bind address and port arrive with Server.bootstrap(ip, port) after the kernel has started, and the listener outlives a kernel restart (Server.reload never rebinds), so the server drives Networking.start and Networking.kill at the exact points bootstrap and shutdown always did.

Parameters ​

networking ​

Networking

The networking the server constructed, so its listener is reachable before the kernel starts.

Returns ​

Module

The module to register on the kernel.