Skip to content

API reference / @jsprismarine/prismarine / player/context/ConnectionContext

player/context/ConnectionContext ​

Interfaces ​

ConnectionContext ​

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:131

What a handler of a connection with no player session is handed.

Properties ​

config ​

readonly config: ConnectionConfig

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:137

The settings the handler may read.

connection ​

readonly connection: ClientConnection

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:133

The connection the packet arrived on.

log ​

readonly log: HandlerLog

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:135

Where the handler logs.

login ​

readonly login: LoginServices

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:141

The services a login uses.

protocols ​

readonly protocols: Pick<ProtocolPolicy, "accepted" | "releases" | "codecFor">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:139

Which client protocols the server accepts.


ConnectionHandler ​

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:148

A handler of a packet that arrives before the connection has a player session. It runs in the connection lane, when its packet arrives, and names only phases in which no session exists.

Extends ​

Type Parameters ​

P ​

P

Properties ​

lane ​

readonly lane: "connection"

Defined in: packages/protocol/src/handler/PacketHandler.ts:41

When the handler runs relative to the world tick.

Inherited from ​

LaneHandler.lane

phases ​

readonly phases: readonly ConnectionPhase[]

Defined in: packages/protocol/src/handler/PacketHandler.ts:23

The session phases in which the packet is accepted. The side drops it in any other.

Inherited from ​

LaneHandler.phases

Methods ​

handle() ​

handle(packet, context): void | Promise<void>

Defined in: packages/protocol/src/handler/PacketHandler.ts:31

Handles one packet.

Parameters ​
packet ​

P

The decoded packet.

context ​

ConnectionContext

What the side hands the handler.

Returns ​

void | Promise<void>

Inherited from ​

LaneHandler.handle


JoinOptions ​

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:65

What a login's edition sets on the player it builds, such as its skin, before anyone sees it.

Methods ​

dress()? ​

optional dress(player): void | Promise<void>

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:67

Sets what the login carried on the player, before the player is filed.

Parameters ​
player ​

StorePlayer

Returns ​

void | Promise<void>

presenterOf()? ​

optional presenterOf(player): SessionPresenter

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:69

What the session's client is shown through; the Bedrock presenter over the connection unless given.

Parameters ​
player ​

StorePlayer

Returns ​

SessionPresenter


JoinPreparation ​

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:73

Builds a login's player in front of its join, for either edition.

Methods ​

prepare() ​

prepare(connection, account, options?): Promise<PlayerSession | null>

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:87

Builds the player of a login that holds its account and joins it to the connection: reads the spawn of the world the player returns to, builds the store player standing there, attaches a session for it and loads its record, which may move it to the world the record names. Sends nothing.

Parameters ​
connection ​

ClientConnection

The connection logging in.

account ​

PlayerIdentity

The account the player plays as, with any link resolved.

options? ​

JoinOptions

What the edition sets on the player, and its presenter.

Returns ​

Promise<PlayerSession | null>

The session, or null when a later login of the same account took it while the spawn was read.

Throws ​

The error loading the record threw, after the session is torn down again.


LoginServices ​

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:95

The server-wide services a login uses.

Properties ​

allowList ​

readonly allowList: Pick<AllowList, "allows" | "ignoresPlayerLimit">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:101

The allow list, which turns away a player not on it while it is on.

bans ​

readonly bans: Pick<BanManager, "isBanned" | "claimLegacy">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:99

The ban list.

readonly links: Pick<AccountLinks, "resolve">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:110

The account links, which make a linked account's login hold the primary's account, so it replaces the primary's session on the other edition rather than playing beside it.

permissions ​

readonly permissions: Pick<PermissionManager, "claimLegacy">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:103

The operator list, which a login may claim an entry of.

players ​

readonly players: JoinPreparation

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:112

Where a login's player is built.

resourcePacks ​

readonly resourcePacks: Pick<ServedResourcePacks, "packs" | "hasAddonPacks" | "subpacks">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:114

The resource packs the server offers, which the login lists for the client.

sessions ​

readonly sessions: Pick<SessionManager, "getSessions" | "reserveIdentity" | "holdsIdentity" | "claimIdentity">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:97

The live connections and the accounts their logins hold.

users ​

readonly users: Pick<UserCache, "remember">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:105

The accounts that have joined, which a login that is let in is recorded in.

Methods ​

removeAsInput() ​

removeAsInput(connection, remove): Promise<void>

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:127

Takes a replaced connection's player out as that connection's next input, behind every input its client sent first, as a transport disconnect does. Kicked from the connection lane instead, the player left at once and the input step dropped what its client had already sent, so the record the new login reads lacked it.

Parameters ​
connection ​

ClientConnection

The connection being replaced; its inputs are held under it.

remove ​

() => Promise<void>

Starts the removal, and takes the player out before it first awaits, as PlayerSession.kick does.

Returns ​

Promise<void>

Settles once the input step that applied the removal is over and the removal has finished.

Type Aliases ​

ConnectionConfig ​

ConnectionConfig = Pick<Config, "getPacketCompressionAlgorithm" | "getPacketCompressionThreshold" | "getMaxPlayers" | "getOnlineMode" | "getTexturepackRequired" | "getDisableClientVibrantVisuals">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:54

The server settings a handler before the session may read.


ConnectionPhase ​

ConnectionPhase = Extract<SessionPhase, "handshake" | "login" | "encryption">

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:36

The phases a connection passes through before its login becomes a player session.


LoginIdentity ​

LoginIdentity = ReturnType<typeof parseLoginIdentity>

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:39

What a login claims about its player, once the claims are verified when they can be.

Functions ​

accountOf() ​

accountOf(identity): PlayerIdentity

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:46

The account a login names, in the form SessionManager compares and a session holds.

Parameters ​

identity ​

Who the login names.

authenticationType ​

number

clientRandomId ​

number = clientData.ClientRandomId

device ​

Device = ...

displayName ​

string

identity ​

string

identityPublicKey ​

string | undefined

languageCode ​

string = clientData.LanguageCode

serverAddress ​

string = clientData.ServerAddress

skin ​

Skin = ...

verified ​

boolean = false

Whether the chain was checked against Xbox Live. Set by the login handler, never by a parse.

xuid ​

string = ...

Returns ​

PlayerIdentity


takesConnection() ​

takesConnection<P>(handler): handler is ConnectionHandler<P>

Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:161

Whether a registered handler takes a ConnectionContext rather than a player session's.

Derived from the handler's declared phases: a session is attached when a connection leaves the login phase, so a handler whose phases all precede that point is one written against the bare connection.

Type Parameters ​

P ​

P

Parameters ​

handler ​

ConnectionHandler<P> | { phases: readonly SessionPhase[]; }

Any handler the registry holds.

Returns ​

handler is ConnectionHandler<P>