PocketMine-MP 5.15.1 git-08c6e63aac45a450fe3b437616ee8aa2500e04e2
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 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 ()
 
 getPing ()
 
 getPlayer ()
 
 getPlayerInfo ()
 
 getPort ()
 
 getTypeConverter ()
 
 handleAckReceipt (int $receiptId)
 
 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)
 
 sendDataPacketWithReceipt (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 136 of file NetworkSession.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 190 of file NetworkSession.php.

Member Function Documentation

◆ addToSendBuffer()

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

Definition at line 568 of file NetworkSession.php.

◆ createPlayer()

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

Definition at line 246 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 754 of file NetworkSession.php.

◆ disconnectIncompatibleProtocol()

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

Definition at line 774 of file NetworkSession.php.

◆ disconnectWithError()

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

Definition at line 765 of file NetworkSession.php.

◆ encodePacketTimed()

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

Definition at line 554 of file NetworkSession.php.

◆ getBroadcaster()

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

Definition at line 601 of file NetworkSession.php.

◆ getCompressor()

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

Definition at line 605 of file NetworkSession.php.

◆ getDisplayName()

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

Definition at line 315 of file NetworkSession.php.

◆ getEntityEventBroadcaster()

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

Definition at line 603 of file NetworkSession.php.

◆ getHandler()

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

Definition at line 333 of file NetworkSession.php.

◆ getInvManager()

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

Definition at line 1232 of file NetworkSession.php.

◆ getIp()

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

Definition at line 307 of file NetworkSession.php.

◆ getLogger()

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

Definition at line 225 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 322 of file NetworkSession.php.

◆ getPlayer()

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

Definition at line 295 of file NetworkSession.php.

◆ getPlayerInfo()

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

Definition at line 299 of file NetworkSession.php.

◆ getPort()

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

Definition at line 311 of file NetworkSession.php.

◆ getTypeConverter()

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

Definition at line 609 of file NetworkSession.php.

◆ handleAckReceipt()

pocketmine\network\mcpe\NetworkSession::handleAckReceipt ( int  $receiptId)

Definition at line 479 of file NetworkSession.php.

◆ handleDataPacket()

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

Definition at line 424 of file NetworkSession.php.

◆ handleEncoded()

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

Definition at line 349 of file NetworkSession.php.

◆ isConnected()

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

Definition at line 303 of file NetworkSession.php.

◆ notifyTerrainReady()

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

Definition at line 946 of file NetworkSession.php.

◆ onActionBar()

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

Definition at line 1263 of file NetworkSession.php.

◆ onChatMessage()

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

Definition at line 1137 of file NetworkSession.php.

◆ onClearTitle()

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

Definition at line 1267 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 809 of file NetworkSession.php.

◆ onEnterWorld()

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

Definition at line 1214 of file NetworkSession.php.

◆ onFormSent()

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

Definition at line 1169 of file NetworkSession.php.

◆ onJukeboxPopup()

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

Definition at line 1149 of file NetworkSession.php.

◆ onOpenSignEditor()

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

Definition at line 1283 of file NetworkSession.php.

◆ onPlayerAdded()

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

Definition at line 1245 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 799 of file NetworkSession.php.

◆ onPlayerRemoved()

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

Definition at line 1249 of file NetworkSession.php.

◆ onPopup()

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

Definition at line 1161 of file NetworkSession.php.

◆ onResetTitleOptions()

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

Definition at line 1271 of file NetworkSession.php.

◆ onServerDeath()

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

Definition at line 960 of file NetworkSession.php.

◆ onServerRespawn()

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

Definition at line 966 of file NetworkSession.php.

◆ onSubTitle()

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

Definition at line 1259 of file NetworkSession.php.

◆ onTip()

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

Definition at line 1165 of file NetworkSession.php.

◆ onTitle()

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

Definition at line 1255 of file NetworkSession.php.

◆ onTitleDuration()

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

Definition at line 1275 of file NetworkSession.php.

◆ onToastNotification()

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

Definition at line 1279 of file NetworkSession.php.

◆ prepareClientTranslatableMessage()

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

Definition at line 1130 of file NetworkSession.php.

◆ queueCompressed()

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

Definition at line 611 of file NetworkSession.php.

◆ sendDataPacket()

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

Definition at line 534 of file NetworkSession.php.

◆ sendDataPacketWithReceipt()

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

@phpstan-return Promise<true>

Definition at line 541 of file NetworkSession.php.

◆ setHandler()

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

Definition at line 337 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 1178 of file NetworkSession.php.

◆ stopUsingChunk()

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

Definition at line 1210 of file NetworkSession.php.

◆ syncAbilities()

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

Definition at line 1028 of file NetworkSession.php.

◆ syncAdventureSettings()

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

Definition at line 1075 of file NetworkSession.php.

◆ syncAvailableCommands()

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

Definition at line 1089 of file NetworkSession.php.

◆ syncGameMode()

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

Definition at line 1017 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 975 of file NetworkSession.php.

◆ syncPlayerList()

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

Definition at line 1239 of file NetworkSession.php.

◆ syncPlayerSpawnPoint()

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

Definition at line 1007 of file NetworkSession.php.

◆ syncViewAreaCenterPoint()

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

Definition at line 1003 of file NetworkSession.php.

◆ syncViewAreaRadius()

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

Definition at line 999 of file NetworkSession.php.

◆ syncWorldDifficulty()

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

Definition at line 1228 of file NetworkSession.php.

◆ syncWorldSpawnPoint()

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

Definition at line 1013 of file NetworkSession.php.

◆ syncWorldTime()

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

Definition at line 1224 of file NetworkSession.php.

◆ tick()

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

Definition at line 1287 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 786 of file NetworkSession.php.

◆ updatePing()

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

Definition at line 329 of file NetworkSession.php.


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