PocketMine-MP 5.11.1 git-db894e3a4a5bb9a80b3ac07ac91f58bdaf15176a
pocketmine\network\mcpe\NetworkSession Class Reference
+ Collaboration diagram for pocketmine\network\mcpe\NetworkSession:

Public Member Functions

 __construct (private Server $server, private NetworkSessionManager $manager, private PacketPool $packetPool, private PacketSerializerContext $packetSerializerContext, private PacketSender $sender, private PacketBroadcaster $broadcaster, private EntityEventBroadcaster $entityEventBroadcaster, private Compressor $compressor, private TypeConverter $typeConverter, private string $ip, private int $port)
 
 addToSendBuffer (string $buffer)
 
 disconnect (Translatable|string $reason, Translatable|string|null $disconnectScreenMessage=null, bool $notify=true)
 
 disconnectIncompatibleProtocol (int $protocolVersion)
 
 disconnectWithError (Translatable|string $reason, Translatable|string|null $disconnectScreenMessage=null)
 
 getBroadcaster ()
 
 getCompressor ()
 
 getDisplayName ()
 
 getEntityEventBroadcaster ()
 
 getHandler ()
 
 getInvManager ()
 
 getIp ()
 
 getLogger ()
 
 getPacketSerializerContext ()
 
 getPing ()
 
 getPlayer ()
 
 getPlayerInfo ()
 
 getPort ()
 
 getTypeConverter ()
 
 handleDataPacket (Packet $packet, string $buffer)
 
 handleEncoded (string $payload)
 
 isConnected ()
 
 notifyTerrainReady ()
 
 onActionBar (string $actionBar)
 
 onChatMessage (Translatable|string $message)
 
 onClearTitle ()
 
 onClientDisconnect (Translatable|string $reason)
 
 onEnterWorld ()
 
 onFormSent (int $id, Form $form)
 
 onJukeboxPopup (Translatable|string $message)
 
 onOpenSignEditor (Vector3 $signPosition, bool $frontSide)
 
 onPlayerAdded (Player $p)
 
 onPlayerDestroyed (Translatable|string $reason, Translatable|string $disconnectScreenMessage)
 
 onPlayerRemoved (Player $p)
 
 onPopup (string $message)
 
 onResetTitleOptions ()
 
 onServerDeath (Translatable|string $deathMessage)
 
 onServerRespawn ()
 
 onSubTitle (string $subtitle)
 
 onTip (string $message)
 
 onTitle (string $title)
 
 onTitleDuration (int $fadeIn, int $stay, int $fadeOut)
 
 onToastNotification (string $title, string $body)
 
 prepareClientTranslatableMessage (Translatable $message)
 
 queueCompressed (CompressBatchPromise|string $payload, bool $immediate=false)
 
 sendDataPacket (ClientboundPacket $packet, bool $immediate=false)
 
 setHandler (?PacketHandler $handler)
 
 startUsingChunk (int $chunkX, int $chunkZ, \Closure $onCompletion)
 
 stopUsingChunk (int $chunkX, int $chunkZ)
 
 syncAbilities (Player $for)
 
 syncAdventureSettings ()
 
 syncAvailableCommands ()
 
 syncGameMode (GameMode $mode, bool $isRollback=false)
 
 syncMovement (Vector3 $pos, ?float $yaw=null, ?float $pitch=null, int $mode=MovePlayerPacket::MODE_NORMAL)
 
 syncPlayerList (array $players)
 
 syncPlayerSpawnPoint (Position $newSpawn)
 
 syncViewAreaCenterPoint (Vector3 $newPos, int $viewDistance)
 
 syncViewAreaRadius (int $distance)
 
 syncWorldDifficulty (int $worldDifficulty)
 
 syncWorldSpawnPoint (Position $newSpawn)
 
 syncWorldTime (int $worldTime)
 
 tick ()
 
 transfer (string $ip, int $port, Translatable|string|null $reason=null)
 
 updatePing (int $ping)
 

Static Public Member Functions

static encodePacketTimed (PacketSerializer $serializer, ClientboundPacket $packet)
 

Protected Member Functions

 createPlayer ()
 

Detailed Description

Definition at line 134 of file NetworkSession.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\network\mcpe\NetworkSession::__construct ( private Server  $server,
private NetworkSessionManager  $manager,
private PacketPool  $packetPool,
private PacketSerializerContext  $packetSerializerContext,
private PacketSender  $sender,
private PacketBroadcaster  $broadcaster,
private EntityEventBroadcaster  $entityEventBroadcaster,
private Compressor  $compressor,
private TypeConverter  $typeConverter,
private string  $ip,
private int  $port 
)

Definition at line 179 of file NetworkSession.php.

Member Function Documentation

◆ addToSendBuffer()

pocketmine\network\mcpe\NetworkSession::addToSendBuffer ( string  $buffer)

Definition at line 526 of file NetworkSession.php.

◆ createPlayer()

pocketmine\network\mcpe\NetworkSession::createPlayer ( )
protected

Definition at line 236 of file NetworkSession.php.

◆ disconnect()

pocketmine\network\mcpe\NetworkSession::disconnect ( Translatable|string  $reason,
Translatable|string|null  $disconnectScreenMessage = null,
bool  $notify = true 
)

Disconnects the session, destroying the associated player (if it exists).

Parameters
Translatable | string$reasonShown in the server log - this should be a short one-line message
Translatable | string | null$disconnectScreenMessageShown on the player's disconnection screen (null will use the reason)

Definition at line 683 of file NetworkSession.php.

◆ disconnectIncompatibleProtocol()

pocketmine\network\mcpe\NetworkSession::disconnectIncompatibleProtocol ( int  $protocolVersion)

Definition at line 703 of file NetworkSession.php.

◆ disconnectWithError()

pocketmine\network\mcpe\NetworkSession::disconnectWithError ( Translatable|string  $reason,
Translatable|string|null  $disconnectScreenMessage = null 
)

Definition at line 694 of file NetworkSession.php.

◆ encodePacketTimed()

static pocketmine\network\mcpe\NetworkSession::encodePacketTimed ( PacketSerializer  $serializer,
ClientboundPacket  $packet 
)
static

Definition at line 512 of file NetworkSession.php.

◆ getBroadcaster()

pocketmine\network\mcpe\NetworkSession::getBroadcaster ( )

Definition at line 559 of file NetworkSession.php.

◆ getCompressor()

pocketmine\network\mcpe\NetworkSession::getCompressor ( )

Definition at line 563 of file NetworkSession.php.

◆ getDisplayName()

pocketmine\network\mcpe\NetworkSession::getDisplayName ( )

Definition at line 305 of file NetworkSession.php.

◆ getEntityEventBroadcaster()

pocketmine\network\mcpe\NetworkSession::getEntityEventBroadcaster ( )

Definition at line 561 of file NetworkSession.php.

◆ getHandler()

pocketmine\network\mcpe\NetworkSession::getHandler ( )

Definition at line 323 of file NetworkSession.php.

◆ getInvManager()

pocketmine\network\mcpe\NetworkSession::getInvManager ( )

Definition at line 1149 of file NetworkSession.php.

◆ getIp()

pocketmine\network\mcpe\NetworkSession::getIp ( )

Definition at line 297 of file NetworkSession.php.

◆ getLogger()

pocketmine\network\mcpe\NetworkSession::getLogger ( )

Definition at line 215 of file NetworkSession.php.

◆ getPacketSerializerContext()

pocketmine\network\mcpe\NetworkSession::getPacketSerializerContext ( )

Definition at line 557 of file NetworkSession.php.

◆ getPing()

pocketmine\network\mcpe\NetworkSession::getPing ( )

Returns the last recorded ping measurement for this session, in milliseconds, or null if a ping measurement has not yet been recorded.

Definition at line 312 of file NetworkSession.php.

◆ getPlayer()

pocketmine\network\mcpe\NetworkSession::getPlayer ( )

Definition at line 285 of file NetworkSession.php.

◆ getPlayerInfo()

pocketmine\network\mcpe\NetworkSession::getPlayerInfo ( )

Definition at line 289 of file NetworkSession.php.

◆ getPort()

pocketmine\network\mcpe\NetworkSession::getPort ( )

Definition at line 301 of file NetworkSession.php.

◆ getTypeConverter()

pocketmine\network\mcpe\NetworkSession::getTypeConverter ( )

Definition at line 567 of file NetworkSession.php.

◆ handleDataPacket()

pocketmine\network\mcpe\NetworkSession::handleDataPacket ( Packet  $packet,
string  $buffer 
)
Exceptions
PacketHandlingException

Definition at line 418 of file NetworkSession.php.

◆ handleEncoded()

pocketmine\network\mcpe\NetworkSession::handleEncoded ( string  $payload)
Exceptions
PacketHandlingException

Definition at line 339 of file NetworkSession.php.

◆ isConnected()

pocketmine\network\mcpe\NetworkSession::isConnected ( )

Definition at line 293 of file NetworkSession.php.

◆ notifyTerrainReady()

pocketmine\network\mcpe\NetworkSession::notifyTerrainReady ( )

Definition at line 863 of file NetworkSession.php.

◆ onActionBar()

pocketmine\network\mcpe\NetworkSession::onActionBar ( string  $actionBar)

Definition at line 1180 of file NetworkSession.php.

◆ onChatMessage()

pocketmine\network\mcpe\NetworkSession::onChatMessage ( Translatable|string  $message)

Definition at line 1054 of file NetworkSession.php.

◆ onClearTitle()

pocketmine\network\mcpe\NetworkSession::onClearTitle ( )

Definition at line 1184 of file NetworkSession.php.

◆ onClientDisconnect()

pocketmine\network\mcpe\NetworkSession::onClientDisconnect ( Translatable|string  $reason)

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.

Definition at line 738 of file NetworkSession.php.

◆ onEnterWorld()

pocketmine\network\mcpe\NetworkSession::onEnterWorld ( )

Definition at line 1131 of file NetworkSession.php.

◆ onFormSent()

pocketmine\network\mcpe\NetworkSession::onFormSent ( int  $id,
Form  $form 
)

Definition at line 1086 of file NetworkSession.php.

◆ onJukeboxPopup()

pocketmine\network\mcpe\NetworkSession::onJukeboxPopup ( Translatable|string  $message)

Definition at line 1066 of file NetworkSession.php.

◆ onOpenSignEditor()

pocketmine\network\mcpe\NetworkSession::onOpenSignEditor ( Vector3  $signPosition,
bool  $frontSide 
)

Definition at line 1200 of file NetworkSession.php.

◆ onPlayerAdded()

pocketmine\network\mcpe\NetworkSession::onPlayerAdded ( Player  $p)

Definition at line 1162 of file NetworkSession.php.

◆ onPlayerDestroyed()

pocketmine\network\mcpe\NetworkSession::onPlayerDestroyed ( Translatable|string  $reason,
Translatable|string  $disconnectScreenMessage 
)

Called by the Player when it is closed (for example due to getting kicked).

Definition at line 728 of file NetworkSession.php.

◆ onPlayerRemoved()

pocketmine\network\mcpe\NetworkSession::onPlayerRemoved ( Player  $p)

Definition at line 1166 of file NetworkSession.php.

◆ onPopup()

pocketmine\network\mcpe\NetworkSession::onPopup ( string  $message)

Definition at line 1078 of file NetworkSession.php.

◆ onResetTitleOptions()

pocketmine\network\mcpe\NetworkSession::onResetTitleOptions ( )

Definition at line 1188 of file NetworkSession.php.

◆ onServerDeath()

pocketmine\network\mcpe\NetworkSession::onServerDeath ( Translatable|string  $deathMessage)

Definition at line 877 of file NetworkSession.php.

◆ onServerRespawn()

pocketmine\network\mcpe\NetworkSession::onServerRespawn ( )

Definition at line 883 of file NetworkSession.php.

◆ onSubTitle()

pocketmine\network\mcpe\NetworkSession::onSubTitle ( string  $subtitle)

Definition at line 1176 of file NetworkSession.php.

◆ onTip()

pocketmine\network\mcpe\NetworkSession::onTip ( string  $message)

Definition at line 1082 of file NetworkSession.php.

◆ onTitle()

pocketmine\network\mcpe\NetworkSession::onTitle ( string  $title)

Definition at line 1172 of file NetworkSession.php.

◆ onTitleDuration()

pocketmine\network\mcpe\NetworkSession::onTitleDuration ( int  $fadeIn,
int  $stay,
int  $fadeOut 
)

Definition at line 1192 of file NetworkSession.php.

◆ onToastNotification()

pocketmine\network\mcpe\NetworkSession::onToastNotification ( string  $title,
string  $body 
)

Definition at line 1196 of file NetworkSession.php.

◆ prepareClientTranslatableMessage()

pocketmine\network\mcpe\NetworkSession::prepareClientTranslatableMessage ( Translatable  $message)
Returns
string[][] @phpstan-return array{string, string[]}

Definition at line 1047 of file NetworkSession.php.

◆ queueCompressed()

pocketmine\network\mcpe\NetworkSession::queueCompressed ( CompressBatchPromise|string  $payload,
bool  $immediate = false 
)

Definition at line 569 of file NetworkSession.php.

◆ sendDataPacket()

pocketmine\network\mcpe\NetworkSession::sendDataPacket ( ClientboundPacket  $packet,
bool  $immediate = false 
)

Definition at line 473 of file NetworkSession.php.

◆ setHandler()

pocketmine\network\mcpe\NetworkSession::setHandler ( ?PacketHandler  $handler)

Definition at line 327 of file NetworkSession.php.

◆ startUsingChunk()

pocketmine\network\mcpe\NetworkSession::startUsingChunk ( int  $chunkX,
int  $chunkZ,
\Closure  $onCompletion 
)

Instructs the networksession to start using the chunk at the given coordinates. This may occur asynchronously.

Parameters
\Closure$onCompletionTo be called when chunk sending has completed. @phpstan-param \Closure() : void $onCompletion

Definition at line 1095 of file NetworkSession.php.

◆ stopUsingChunk()

pocketmine\network\mcpe\NetworkSession::stopUsingChunk ( int  $chunkX,
int  $chunkZ 
)

Definition at line 1127 of file NetworkSession.php.

◆ syncAbilities()

pocketmine\network\mcpe\NetworkSession::syncAbilities ( Player  $for)

Definition at line 945 of file NetworkSession.php.

◆ syncAdventureSettings()

pocketmine\network\mcpe\NetworkSession::syncAdventureSettings ( )

Definition at line 992 of file NetworkSession.php.

◆ syncAvailableCommands()

pocketmine\network\mcpe\NetworkSession::syncAvailableCommands ( )

Definition at line 1006 of file NetworkSession.php.

◆ syncGameMode()

pocketmine\network\mcpe\NetworkSession::syncGameMode ( GameMode  $mode,
bool  $isRollback = false 
)

Definition at line 934 of file NetworkSession.php.

◆ syncMovement()

pocketmine\network\mcpe\NetworkSession::syncMovement ( Vector3  $pos,
?float  $yaw = null,
?float  $pitch = null,
int  $mode = MovePlayerPacket::MODE_NORMAL 
)

Definition at line 892 of file NetworkSession.php.

◆ syncPlayerList()

pocketmine\network\mcpe\NetworkSession::syncPlayerList ( array  $players)
Parameters
Player[]$players

Definition at line 1156 of file NetworkSession.php.

◆ syncPlayerSpawnPoint()

pocketmine\network\mcpe\NetworkSession::syncPlayerSpawnPoint ( Position  $newSpawn)

Definition at line 924 of file NetworkSession.php.

◆ syncViewAreaCenterPoint()

pocketmine\network\mcpe\NetworkSession::syncViewAreaCenterPoint ( Vector3  $newPos,
int  $viewDistance 
)

Definition at line 920 of file NetworkSession.php.

◆ syncViewAreaRadius()

pocketmine\network\mcpe\NetworkSession::syncViewAreaRadius ( int  $distance)

Definition at line 916 of file NetworkSession.php.

◆ syncWorldDifficulty()

pocketmine\network\mcpe\NetworkSession::syncWorldDifficulty ( int  $worldDifficulty)

Definition at line 1145 of file NetworkSession.php.

◆ syncWorldSpawnPoint()

pocketmine\network\mcpe\NetworkSession::syncWorldSpawnPoint ( Position  $newSpawn)

Definition at line 930 of file NetworkSession.php.

◆ syncWorldTime()

pocketmine\network\mcpe\NetworkSession::syncWorldTime ( int  $worldTime)

Definition at line 1141 of file NetworkSession.php.

◆ tick()

pocketmine\network\mcpe\NetworkSession::tick ( )

Definition at line 1204 of file NetworkSession.php.

◆ transfer()

pocketmine\network\mcpe\NetworkSession::transfer ( string  $ip,
int  $port,
Translatable|string|null  $reason = null 
)

Instructs the remote client to connect to a different server.

Definition at line 715 of file NetworkSession.php.

◆ updatePing()

pocketmine\network\mcpe\NetworkSession::updatePing ( int  $ping)

Definition at line 319 of file NetworkSession.php.


The documentation for this class was generated from the following file: