PocketMine-MP 5.21.1 git-2ff647079265e7c600203af4fd902b15e99d49a4
raklib\generic\Session Class Reference
+ Inheritance diagram for raklib\generic\Session:
+ Collaboration diagram for raklib\generic\Session:

Public Member Functions

 __construct (\Logger $logger, InternetAddress $address, int $clientId, int $mtuSize, int $recvMaxSplitParts=PHP_INT_MAX, int $recvMaxConcurrentSplits=PHP_INT_MAX)
 
 addEncapsulatedToQueue (EncapsulatedPacket $packet, bool $immediate)
 
 forciblyDisconnect (int $reason)
 
 getAddress ()
 
 getID ()
 
 getState ()
 
 handlePacket (Packet $packet)
 
 initiateDisconnect (int $reason)
 
 isConnected ()
 
 isFullyDisconnected ()
 
 isTemporary ()
 
 update (float $time)
 

Public Attributes

const MIN_MTU_SIZE = 400
 
const STATE_CONNECTED = 1
 
const STATE_CONNECTING = 0
 
const STATE_DISCONNECT_NOTIFIED = 3
 
const STATE_DISCONNECT_PENDING = 2
 
const STATE_DISCONNECTED = 4
 

Protected Member Functions

 getRakNetTimeMS ()
 
 handleRakNetConnectionPacket (string $packet)
 
 onDisconnect (int $reason)
 
 onPacketAck (int $identifierACK)
 
 onPacketReceive (string $packet)
 
 onPingMeasure (int $pingMS)
 
 queueConnectedPacket (ConnectedPacket $packet, int $reliability, int $orderChannel, bool $immediate=false)
 
 sendPacket (Packet $packet)
 
 sendPing (int $reliability=PacketReliability::UNRELIABLE)
 

Protected Attributes

InternetAddress $address
 
int $state = self::STATE_CONNECTING
 

Detailed Description

Definition at line 39 of file Session.php.

Constructor & Destructor Documentation

◆ __construct()

raklib\generic\Session::__construct ( \Logger  $logger,
InternetAddress  $address,
int  $clientId,
int  $mtuSize,
int  $recvMaxSplitParts = PHP_INT_MAX,
int  $recvMaxConcurrentSplits = PHP_INT_MAX 
)

@phpstan-param positive-int $recvMaxSplitParts @phpstan-param positive-int $recvMaxConcurrentSplits

Definition at line 73 of file Session.php.

References raklib\generic\Session\onPacketAck(), and raklib\generic\Session\sendPacket().

+ Here is the call graph for this function:

Member Function Documentation

◆ addEncapsulatedToQueue()

raklib\generic\Session::addEncapsulatedToQueue ( EncapsulatedPacket  $packet,
bool  $immediate 
)

Definition at line 230 of file Session.php.

◆ forciblyDisconnect()

raklib\generic\Session::forciblyDisconnect ( int  $reason)

Disconnects the session with immediate effect, regardless of current session state. Usually used in timeout cases.

Parameters
int$reasonone of the DisconnectReason constants @phpstan-param DisconnectReason::* $reason
See also
DisconnectReason

Definition at line 316 of file Session.php.

◆ getAddress()

raklib\generic\Session::getAddress ( )

Definition at line 158 of file Session.php.

◆ getID()

raklib\generic\Session::getID ( )

Definition at line 162 of file Session.php.

◆ getRakNetTimeMS()

raklib\generic\Session::getRakNetTimeMS ( )
protected

Returns a monotonically increasing timestamp. It does not need to match UNIX time. This is used to calculate ping.

Definition at line 154 of file Session.php.

◆ getState()

raklib\generic\Session::getState ( )

Definition at line 166 of file Session.php.

◆ handlePacket()

raklib\generic\Session::handlePacket ( Packet  $packet)

Definition at line 278 of file Session.php.

◆ handleRakNetConnectionPacket()

raklib\generic\Session::handleRakNetConnectionPacket ( string  $packet)
abstractprotected

Called when a packet is received while the session is in the "connecting" state. This should only handle RakNet connection packets. Any other packets should be ignored.

Reimplemented in raklib\server\ServerSession.

◆ initiateDisconnect()

raklib\generic\Session::initiateDisconnect ( int  $reason)

Initiates a graceful asynchronous disconnect which ensures both parties got all packets.

Parameters
int$reasonone of the DisconnectReason constants @phpstan-param DisconnectReason::* $reason
See also
DisconnectReason

Definition at line 299 of file Session.php.

◆ isConnected()

raklib\generic\Session::isConnected ( )

Definition at line 174 of file Session.php.

◆ isFullyDisconnected()

raklib\generic\Session::isFullyDisconnected ( )

Returns whether the session is ready to be destroyed (either properly cleaned up or forcibly terminated)

Definition at line 339 of file Session.php.

◆ isTemporary()

raklib\generic\Session::isTemporary ( )

Definition at line 170 of file Session.php.

◆ onDisconnect()

raklib\generic\Session::onDisconnect ( int  $reason)
abstractprotected

Called when the session is terminated for any reason.

Parameters
int$reasonone of the DisconnectReason::* constants @phpstan-param DisconnectReason::* $reason
See also
DisconnectReason

Reimplemented in raklib\server\ServerSession.

◆ onPacketAck()

raklib\generic\Session::onPacketAck ( int  $identifierACK)
abstractprotected

Called when a packet for which an ACK was requested is ACKed.

Reimplemented in raklib\server\ServerSession.

Referenced by raklib\generic\Session\__construct().

+ Here is the caller graph for this function:

◆ onPacketReceive()

raklib\generic\Session::onPacketReceive ( string  $packet)
abstractprotected

Called when a user packet (ID >= ID_USER_PACKET_ENUM) is received from the remote peer.

See also
MessageIdentifiers::ID_USER_PACKET_ENUM

Reimplemented in raklib\server\ServerSession.

◆ onPingMeasure()

raklib\generic\Session::onPingMeasure ( int  $pingMS)
abstractprotected

Called when a new ping measurement is recorded.

Reimplemented in raklib\server\ServerSession.

◆ queueConnectedPacket()

raklib\generic\Session::queueConnectedPacket ( ConnectedPacket  $packet,
int  $reliability,
int  $orderChannel,
bool  $immediate = false 
)
protected

Definition at line 218 of file Session.php.

◆ sendPacket()

raklib\generic\Session::sendPacket ( Packet  $packet)
abstractprotected

Sends a packet in the appropriate way for the session type.

Reimplemented in raklib\server\ServerSession.

Referenced by raklib\generic\Session\__construct().

+ Here is the caller graph for this function:

◆ sendPing()

raklib\generic\Session::sendPing ( int  $reliability = PacketReliability::UNRELIABLE)
protected

Definition at line 234 of file Session.php.

◆ update()

raklib\generic\Session::update ( float  $time)

Definition at line 181 of file Session.php.

Member Data Documentation

◆ $address

InternetAddress raklib\generic\Session::$address
protected

Definition at line 50 of file Session.php.

◆ $state

int raklib\generic\Session::$state = self::STATE_CONNECTING
protected

Definition at line 52 of file Session.php.

◆ MIN_MTU_SIZE

const raklib\generic\Session::MIN_MTU_SIZE = 400

Definition at line 46 of file Session.php.

◆ STATE_CONNECTED

const raklib\generic\Session::STATE_CONNECTED = 1

Definition at line 41 of file Session.php.

◆ STATE_CONNECTING

const raklib\generic\Session::STATE_CONNECTING = 0

Definition at line 40 of file Session.php.

◆ STATE_DISCONNECT_NOTIFIED

const raklib\generic\Session::STATE_DISCONNECT_NOTIFIED = 3

Definition at line 43 of file Session.php.

◆ STATE_DISCONNECT_PENDING

const raklib\generic\Session::STATE_DISCONNECT_PENDING = 2

Definition at line 42 of file Session.php.

◆ STATE_DISCONNECTED

const raklib\generic\Session::STATE_DISCONNECTED = 4

Definition at line 44 of file Session.php.


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