NetworkSession
in package
Table of Contents
- $authenticated : bool
- $broadcaster : PacketBroadcaster
- $cachedOfflinePlayerData : CompoundTag|null
- $cipher : EncryptionContext|null
- $compressedQueue : SplQueue
- $compressor : Compressor
- $connected : bool
- $connectTime : int
- $disconnectGuard : bool
- $disposeHooks : ObjectSet
- $forceAsyncCompression : bool
- $handler : PacketHandler|null
- $info : PlayerInfo|null
- $invManager : InventoryManager|null
- $ip : string
- $loggedIn : bool
- $logger : PrefixedLogger
- $manager : NetworkSessionManager
- $packetPool : PacketPool
- $packetSerializerContext : PacketSerializerContext
- $ping : int|null
- $player : Player|null
- $port : int
- $sendBuffer : array<string|int, mixed>
- $sender : PacketSender
- $server : Server
- __construct() : mixed
- disconnect() : void
- Disconnects the session, destroying the associated player (if it exists).
- getBroadcaster() : PacketBroadcaster
- getCompressor() : Compressor
- getDisplayName() : string
- getHandler() : PacketHandler|null
- getInvManager() : InventoryManager|null
- getIp() : string
- getLogger() : Logger
- getPacketSerializerContext() : PacketSerializerContext
- getPing() : int|null
- Returns the last recorded ping measurement for this session, in milliseconds, or null if a ping measurement has not yet been recorded.
- getPlayer() : Player|null
- getPlayerInfo() : PlayerInfo|null
- getPort() : int
- handleDataPacket() : void
- handleEncoded() : void
- isConnected() : bool
- notifyTerrainReady() : void
- onActionBar() : void
- onClearTitle() : void
- onClientDisconnect() : void
- Called by the network interface to close the session when the client disconnects without server input, for example in a timeout condition or voluntary client disconnect.
- onEmote() : void
- onEnterWorld() : void
- onEntityEffectAdded() : void
- onEntityEffectRemoved() : void
- onEntityRemoved() : void
- onFormSent() : bool
- onJukeboxPopup() : void
- onMobArmorChange() : void
- onMobMainHandItemChange() : void
- TODO: expand this to more than just humans
- onMobOffHandItemChange() : void
- onPlayerAdded() : void
- onPlayerDestroyed() : void
- Called by the Player when it is closed (for example due to getting kicked).
- onPlayerPickUpItem() : void
- onPlayerRemoved() : void
- onPopup() : void
- onRawChatMessage() : void
- onResetTitleOptions() : void
- onServerDeath() : void
- onServerRespawn() : void
- onSubTitle() : void
- onTip() : void
- onTitle() : void
- onTitleDuration() : void
- onTranslatedChatMessage() : void
- queueCompressed() : void
- sendDataPacket() : bool
- setHandler() : void
- startUsingChunk() : void
- Instructs the networksession to start using the chunk at the given coordinates. This may occur asynchronously.
- stopUsingChunk() : void
- syncActorData() : void
- syncAdventureSettings() : void
- TODO: make this less specialized
- syncAttributes() : void
- syncAvailableCommands() : void
- syncGameMode() : void
- syncMovement() : void
- syncPlayerList() : void
- syncPlayerSpawnPoint() : void
- syncViewAreaCenterPoint() : void
- syncViewAreaRadius() : void
- syncWorldDifficulty() : void
- syncWorldSpawnPoint() : void
- syncWorldTime() : void
- tick() : void
- transfer() : void
- Instructs the remote client to connect to a different server.
- createPlayer() : void
- beginSpawnSequence() : void
- doServerDisconnect() : void
- Internal helper function used to handle server disconnections.
- flushSendBuffer() : void
- getLogPrefix() : string
- onClientSpawnResponse() : void
- onPlayerCreated() : void
- onServerLoginSuccess() : void
- queueCompressedNoBufferFlush() : void
- sendEncoded() : void
- setAuthenticationStatus() : void
- tryDisconnect() : void
Properties
$authenticated
private
bool
$authenticated
= false
$broadcaster
private
PacketBroadcaster
$broadcaster
$cachedOfflinePlayerData
private
CompoundTag|null
$cachedOfflinePlayerData
= null
$cipher
private
EncryptionContext|null
$cipher
= null
$compressedQueue
private
SplQueue
$compressedQueue
Tags
$compressor
private
Compressor
$compressor
$connected
private
bool
$connected
= true
$connectTime
private
int
$connectTime
$disconnectGuard
private
bool
$disconnectGuard
= false
$disposeHooks
private
ObjectSet
$disposeHooks
Tags
$forceAsyncCompression
private
bool
$forceAsyncCompression
= true
$handler
private
PacketHandler|null
$handler
= null
$info
private
PlayerInfo|null
$info
= null
$invManager
private
InventoryManager|null
$invManager
= null
$ip
private
string
$ip
$loggedIn
private
bool
$loggedIn
= false
$logger
private
PrefixedLogger
$logger
$manager
private
NetworkSessionManager
$manager
$packetPool
private
PacketPool
$packetPool
$packetSerializerContext
private
PacketSerializerContext
$packetSerializerContext
$ping
private
int|null
$ping
= null
$player
private
Player|null
$player
= null
$port
private
int
$port
$sendBuffer
private
array<string|int, mixed>
$sendBuffer
= []
$sender
private
PacketSender
$sender
$server
private
Server
$server
Methods
__construct()
public
__construct(Server $server, NetworkSessionManager $manager, PacketPool $packetPool, PacketSender $sender, PacketBroadcaster $broadcaster, Compressor $compressor, string $ip, int $port) : mixed
Parameters
- $server : Server
- $manager : NetworkSessionManager
- $packetPool : PacketPool
- $sender : PacketSender
- $broadcaster : PacketBroadcaster
- $compressor : Compressor
- $ip : string
- $port : int
Return values
mixed —disconnect()
Disconnects the session, destroying the associated player (if it exists).
public
disconnect(string $reason[, bool $notify = true ]) : void
Parameters
- $reason : string
- $notify : bool = true
Return values
void —getBroadcaster()
public
getBroadcaster() : PacketBroadcaster
Return values
PacketBroadcaster —getCompressor()
public
getCompressor() : Compressor
Return values
Compressor —getDisplayName()
public
getDisplayName() : string
Return values
string —getHandler()
public
getHandler() : PacketHandler|null
Return values
PacketHandler|null —getInvManager()
public
getInvManager() : InventoryManager|null
Return values
InventoryManager|null —getIp()
public
getIp() : string
Return values
string —getLogger()
public
getLogger() : Logger
Return values
Logger —getPacketSerializerContext()
public
getPacketSerializerContext() : PacketSerializerContext
Return values
PacketSerializerContext —getPing()
Returns the last recorded ping measurement for this session, in milliseconds, or null if a ping measurement has not yet been recorded.
public
getPing() : int|null
Return values
int|null —getPlayer()
public
getPlayer() : Player|null
Return values
Player|null —getPlayerInfo()
public
getPlayerInfo() : PlayerInfo|null
Return values
PlayerInfo|null —getPort()
public
getPort() : int
Return values
int —handleDataPacket()
public
handleDataPacket(Packet $packet, string $buffer) : void
Parameters
- $packet : Packet
- $buffer : string
Tags
Return values
void —handleEncoded()
public
handleEncoded(string $payload) : void
Parameters
- $payload : string
Tags
Return values
void —isConnected()
public
isConnected() : bool
Return values
bool —notifyTerrainReady()
public
notifyTerrainReady() : void
Return values
void —onActionBar()
public
onActionBar(string $actionBar) : void
Parameters
- $actionBar : string
Return values
void —onClearTitle()
public
onClearTitle() : void
Return values
void —onClientDisconnect()
Called by the network interface to close the session when the client disconnects without server input, for example in a timeout condition or voluntary client disconnect.
public
onClientDisconnect(string $reason) : void
Parameters
- $reason : string
Return values
void —onEmote()
public
onEmote(Player $from, string $emoteId) : void
Parameters
- $from : Player
- $emoteId : string
Return values
void —onEnterWorld()
public
onEnterWorld() : void
Return values
void —onEntityEffectAdded()
public
onEntityEffectAdded(Living $entity, EffectInstance $effect, bool $replacesOldEffect) : void
Parameters
- $entity : Living
- $effect : EffectInstance
- $replacesOldEffect : bool
Return values
void —onEntityEffectRemoved()
public
onEntityEffectRemoved(Living $entity, EffectInstance $effect) : void
Parameters
- $entity : Living
- $effect : EffectInstance
Return values
void —onEntityRemoved()
public
onEntityRemoved(Entity $entity) : void
Parameters
- $entity : Entity
Return values
void —onFormSent()
public
onFormSent(int $id, Form $form) : bool
Parameters
- $id : int
- $form : Form
Return values
bool —onJukeboxPopup()
public
onJukeboxPopup(string $key, array<string|int, string> $parameters) : void
Parameters
- $key : string
- $parameters : array<string|int, string>
Return values
void —onMobArmorChange()
public
onMobArmorChange(Living $mob) : void
Parameters
- $mob : Living
Return values
void —onMobMainHandItemChange()
TODO: expand this to more than just humans
public
onMobMainHandItemChange(Human $mob) : void
Parameters
- $mob : Human
Return values
void —onMobOffHandItemChange()
public
onMobOffHandItemChange(Human $mob) : void
Parameters
- $mob : Human
Return values
void —onPlayerAdded()
public
onPlayerAdded(Player $p) : void
Parameters
- $p : Player
Return values
void —onPlayerDestroyed()
Called by the Player when it is closed (for example due to getting kicked).
public
onPlayerDestroyed(string $reason) : void
Parameters
- $reason : string
Return values
void —onPlayerPickUpItem()
public
onPlayerPickUpItem(Player $collector, Entity $pickedUp) : void
Parameters
Return values
void —onPlayerRemoved()
public
onPlayerRemoved(Player $p) : void
Parameters
- $p : Player
Return values
void —onPopup()
public
onPopup(string $message) : void
Parameters
- $message : string
Return values
void —onRawChatMessage()
public
onRawChatMessage(string $message) : void
Parameters
- $message : string
Return values
void —onResetTitleOptions()
public
onResetTitleOptions() : void
Return values
void —onServerDeath()
public
onServerDeath() : void
Return values
void —onServerRespawn()
public
onServerRespawn() : void
Return values
void —onSubTitle()
public
onSubTitle(string $subtitle) : void
Parameters
- $subtitle : string
Return values
void —onTip()
public
onTip(string $message) : void
Parameters
- $message : string
Return values
void —onTitle()
public
onTitle(string $title) : void
Parameters
- $title : string
Return values
void —onTitleDuration()
public
onTitleDuration(int $fadeIn, int $stay, int $fadeOut) : void
Parameters
- $fadeIn : int
- $stay : int
- $fadeOut : int
Return values
void —onTranslatedChatMessage()
public
onTranslatedChatMessage(string $key, array<string|int, string> $parameters) : void
Parameters
- $key : string
- $parameters : array<string|int, string>
Return values
void —queueCompressed()
public
queueCompressed(CompressBatchPromise $payload[, bool $immediate = false ]) : void
Parameters
- $payload : CompressBatchPromise
- $immediate : bool = false
Return values
void —sendDataPacket()
public
sendDataPacket(ClientboundPacket $packet[, bool $immediate = false ]) : bool
Parameters
- $packet : ClientboundPacket
- $immediate : bool = false
Return values
bool —setHandler()
public
setHandler(PacketHandler|null $handler) : void
Parameters
- $handler : PacketHandler|null
Return values
void —startUsingChunk()
Instructs the networksession to start using the chunk at the given coordinates. This may occur asynchronously.
public
startUsingChunk(int $chunkX, int $chunkZ, Closure $onCompletion) : void
Parameters
- $chunkX : int
- $chunkZ : int
- $onCompletion : Closure
-
To be called when chunk sending has completed.
Tags
Return values
void —stopUsingChunk()
public
stopUsingChunk(int $chunkX, int $chunkZ) : void
Parameters
- $chunkX : int
- $chunkZ : int
Return values
void —syncActorData()
public
syncActorData(Entity $entity, array<string|int, MetadataProperty> $properties) : void
Parameters
- $entity : Entity
- $properties : array<string|int, MetadataProperty>
Tags
Return values
void —syncAdventureSettings()
TODO: make this less specialized
public
syncAdventureSettings(Player $for) : void
Parameters
- $for : Player
Return values
void —syncAttributes()
public
syncAttributes(Living $entity, array<string|int, Attribute> $attributes) : void
Parameters
Return values
void —syncAvailableCommands()
public
syncAvailableCommands() : void
Return values
void —syncGameMode()
public
syncGameMode(GameMode $mode[, bool $isRollback = false ]) : void
Parameters
- $mode : GameMode
- $isRollback : bool = false
Return values
void —syncMovement()
public
syncMovement(Vector3 $pos[, float|null $yaw = null ][, float|null $pitch = null ][, int $mode = MovePlayerPacket::MODE_NORMAL ]) : void
Parameters
- $pos : Vector3
- $yaw : float|null = null
- $pitch : float|null = null
- $mode : int = MovePlayerPacket::MODE_NORMAL
Return values
void —syncPlayerList()
public
syncPlayerList(array<string|int, Player> $players) : void
Parameters
- $players : array<string|int, Player>
Return values
void —syncPlayerSpawnPoint()
public
syncPlayerSpawnPoint(Position $newSpawn) : void
Parameters
- $newSpawn : Position
Return values
void —syncViewAreaCenterPoint()
public
syncViewAreaCenterPoint(Vector3 $newPos, int $viewDistance) : void
Parameters
- $newPos : Vector3
- $viewDistance : int
Return values
void —syncViewAreaRadius()
public
syncViewAreaRadius(int $distance) : void
Parameters
- $distance : int
Return values
void —syncWorldDifficulty()
public
syncWorldDifficulty(int $worldDifficulty) : void
Parameters
- $worldDifficulty : int
Return values
void —syncWorldSpawnPoint()
public
syncWorldSpawnPoint(Position $newSpawn) : void
Parameters
- $newSpawn : Position
Return values
void —syncWorldTime()
public
syncWorldTime(int $worldTime) : void
Parameters
- $worldTime : int
Return values
void —tick()
public
tick() : void
Return values
void —transfer()
Instructs the remote client to connect to a different server.
public
transfer(string $ip, int $port[, string $reason = "transfer" ]) : void
Parameters
- $ip : string
- $port : int
- $reason : string = "transfer"
Return values
void —createPlayer()
protected
createPlayer() : void
Return values
void —beginSpawnSequence()
private
beginSpawnSequence() : void
Return values
void —doServerDisconnect()
Internal helper function used to handle server disconnections.
private
doServerDisconnect(string $reason[, bool $notify = true ]) : void
Parameters
- $reason : string
- $notify : bool = true
Return values
void —flushSendBuffer()
private
flushSendBuffer([bool $immediate = false ]) : void
Parameters
- $immediate : bool = false
Return values
void —getLogPrefix()
private
getLogPrefix() : string
Return values
string —onClientSpawnResponse()
private
onClientSpawnResponse() : void
Return values
void —onPlayerCreated()
private
onPlayerCreated(Player $player) : void
Parameters
- $player : Player
Return values
void —onServerLoginSuccess()
private
onServerLoginSuccess() : void
Return values
void —queueCompressedNoBufferFlush()
private
queueCompressedNoBufferFlush(CompressBatchPromise $payload[, bool $immediate = false ]) : void
Parameters
- $payload : CompressBatchPromise
- $immediate : bool = false
Return values
void —sendEncoded()
private
sendEncoded(string $payload[, bool $immediate = false ]) : void
Parameters
- $payload : string
- $immediate : bool = false
Return values
void —setAuthenticationStatus()
private
setAuthenticationStatus(bool $authenticated, bool $authRequired, string|null $error, string|null $clientPubKey) : void
Parameters
- $authenticated : bool
- $authRequired : bool
- $error : string|null
- $clientPubKey : string|null
Return values
void —tryDisconnect()
private
tryDisconnect(Closure $func, string $reason) : void
Parameters
- $func : Closure
- $reason : string