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
readonlyconfig:ConnectionConfig
Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:137
The settings the handler may read.
connection
readonlyconnection:ClientConnection
Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:133
The connection the packet arrived on.
log
readonlylog:HandlerLog
Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:135
Where the handler logs.
login
readonlylogin:LoginServices
Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:141
The services a login uses.
protocols
readonlyprotocols: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
LaneHandler<P,ConnectionContext,"connection",ConnectionPhase>
Type Parameters
P
P
Properties
lane
readonlylane:"connection"
Defined in: packages/protocol/src/handler/PacketHandler.ts:41
When the handler runs relative to the world tick.
Inherited from
LaneHandler.lane
phases
readonlyphases: readonlyConnectionPhase[]
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
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()?
optionaldress(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
Returns
void | Promise<void>
presenterOf()?
optionalpresenterOf(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
Returns
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
The connection logging in.
account
The account the player plays as, with any link resolved.
options?
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
readonlyallowList: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
readonlybans:Pick<BanManager,"isBanned"|"claimLegacy">
Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:99
The ban list.
links
readonlylinks: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
readonlypermissions: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
readonlyplayers:JoinPreparation
Defined in: packages/prismarine/src/player/context/ConnectionContext.ts:112
Where a login's player is built.
resourcePacks
readonlyresourcePacks: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
readonlysessions: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
readonlyusers: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
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<typeofparseLoginIdentity>
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
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>