API reference / @jsprismarine/prismarine / network/codec/ProtocolPolicy
network/codec/ProtocolPolicy
Interfaces
ProtocolPolicy
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:28
The settings resolved against the codecs this build ships.
Properties
accepted
readonlyaccepted: readonlyProtocolCodec[]
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:32
Every codec a client may negotiate: the releases, and any preview this build has.
clampedFrom?
readonlyoptionalclampedFrom?:number
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:36
The window the settings asked for, when the build has fewer releases than that.
content
readonlycontent:ProtocolCodec
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:34
The release whose content the world holds.
releases
readonlyreleases: readonlyProtocolCodec[]
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:30
The releases accepted, newest first.
Methods
codecFor()
codecFor(
protocolVersion):ProtocolCodec|undefined
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:41
The codec for a client's announced protocol, or undefined when the policy refuses it.
Parameters
protocolVersion
number
The number the client sent in RequestNetworkSettings.
Returns
ProtocolCodec | undefined
ProtocolSettings
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:17
What config.json says about protocols, before it is resolved against this build's codecs.
Properties
content
readonlycontent:ProtocolContent
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:21
Which release in the window the world's content comes from.
window
readonlywindow:number
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:19
How many releases to accept, counted back from the newest.
Type Aliases
ProtocolContent
ProtocolContent =
"newest"|"oldest"
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:14
Which release in the window the world's content comes from.
Variables
DEFAULT_PROTOCOL_SETTINGS
constDEFAULT_PROTOCOL_SETTINGS:ProtocolSettings
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:25
The settings a server without any runs on: the newest release only, with its content.
Functions
resolveProtocolPolicy()
resolveProtocolPolicy(
settings?,codecs?):ProtocolPolicy
Defined in: packages/prismarine/src/network/codec/ProtocolPolicy.ts:53
Resolves protocol settings against a build's codecs.
A window below 1 accepts the newest release only, and a window wider than the releases the build has is clamped to them, so a newer build that dropped an old codec still starts.
Parameters
settings?
ProtocolSettings = DEFAULT_PROTOCOL_SETTINGS
What config.json says.
codecs?
readonly ProtocolCodec[] = registeredCodecs
The build's codecs, newest first. Defaults to the server's.
Returns
The policy the network and the content build read.