pocketmine\Player::getPort PHP Method

getPort() public method

public getPort ( ) : integer
return integer
    public function getPort() : int
    {
        return $this->port;
    }

Usage Example

示例#1
0
文件: Main.php 项目: mwvent/WattzMCPE
 public function forcePlayerDisconnect(Player $player)
 {
     // https://forums.pocketmine.net/threads/temporary-solution-for-transferring-players-in-0-12-1.11759/
     // find out the RakLib interface, which is the network interface that MCPE players connect with
     foreach ($this->getServer()->getNetwork()->getInterfaces() as $interface) {
         if ($interface instanceof RakLibInterface) {
             $raklib = $interface;
             break;
         }
     }
     if (!isset($raklib)) {
         Server::getInstance()->getLogger()->critical(Main::PREFIX . "rakLib not found");
         return;
     }
     // calculate the identifier for the player used by RakLib
     $identifier = $player->getAddress() . ":" . $player->getPort();
     // this method call is the most important one - it sends some signal to RakLib that makes it think that the client has clicked the "Quit to Title" button (or timed out). Some RakLib internal stuff will then tell PocketMine that the player has quitted.
     $raklib->closeSession($identifier, "transfer");
 }
All Usage Examples Of pocketmine\Player::getPort
Player