mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Rename SourceInterface -> NetworkInterface
SourceInterface doesn't make sense really...
This commit is contained in:
@ -30,7 +30,7 @@ namespace pocketmine\network;
|
||||
* Advanced network interfaces have some additional capabilities, such as being able to ban addresses and process raw
|
||||
* packets.
|
||||
*/
|
||||
interface AdvancedSourceInterface extends SourceInterface{
|
||||
interface AdvancedNetworkInterface extends NetworkInterface{
|
||||
|
||||
/**
|
||||
* Prevents packets received from the IP address getting processed for the given timeout.
|
@ -39,10 +39,10 @@ class Network{
|
||||
/** @var Server */
|
||||
private $server;
|
||||
|
||||
/** @var SourceInterface[] */
|
||||
/** @var NetworkInterface[] */
|
||||
private $interfaces = [];
|
||||
|
||||
/** @var AdvancedSourceInterface[] */
|
||||
/** @var AdvancedNetworkInterface[] */
|
||||
private $advancedInterfaces = [];
|
||||
|
||||
private $upload = 0;
|
||||
@ -77,7 +77,7 @@ class Network{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SourceInterface[]
|
||||
* @return NetworkInterface[]
|
||||
*/
|
||||
public function getInterfaces() : array{
|
||||
return $this->interfaces;
|
||||
@ -89,7 +89,7 @@ class Network{
|
||||
}
|
||||
}
|
||||
|
||||
public function processInterface(SourceInterface $interface) : void{
|
||||
public function processInterface(NetworkInterface $interface) : void{
|
||||
try{
|
||||
$interface->process();
|
||||
}catch(\Throwable $e){
|
||||
@ -107,14 +107,14 @@ class Network{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SourceInterface $interface
|
||||
* @param NetworkInterface $interface
|
||||
*/
|
||||
public function registerInterface(SourceInterface $interface) : void{
|
||||
public function registerInterface(NetworkInterface $interface) : void{
|
||||
$this->server->getPluginManager()->callEvent($ev = new NetworkInterfaceRegisterEvent($interface));
|
||||
if(!$ev->isCancelled()){
|
||||
$interface->start();
|
||||
$this->interfaces[$hash = spl_object_hash($interface)] = $interface;
|
||||
if($interface instanceof AdvancedSourceInterface){
|
||||
if($interface instanceof AdvancedNetworkInterface){
|
||||
$this->advancedInterfaces[$hash] = $interface;
|
||||
$interface->setNetwork($this);
|
||||
}
|
||||
@ -123,9 +123,9 @@ class Network{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SourceInterface $interface
|
||||
* @param NetworkInterface $interface
|
||||
*/
|
||||
public function unregisterInterface(SourceInterface $interface) : void{
|
||||
public function unregisterInterface(NetworkInterface $interface) : void{
|
||||
$this->server->getPluginManager()->callEvent(new NetworkInterfaceUnregisterEvent($interface));
|
||||
unset($this->interfaces[$hash = spl_object_hash($interface)], $this->advancedInterfaces[$hash]);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ use pocketmine\Player;
|
||||
/**
|
||||
* Network interfaces are transport layers which can be used to transmit packets between the server and clients.
|
||||
*/
|
||||
interface SourceInterface{
|
||||
interface NetworkInterface{
|
||||
|
||||
/**
|
||||
* Performs actions needed to start the interface after it is registered.
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\event\player\PlayerCreationEvent;
|
||||
use pocketmine\network\AdvancedSourceInterface;
|
||||
use pocketmine\network\AdvancedNetworkInterface;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\PacketPool;
|
||||
@ -41,7 +41,7 @@ use raklib\server\ServerHandler;
|
||||
use raklib\server\ServerInstance;
|
||||
use raklib\utils\InternetAddress;
|
||||
|
||||
class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
||||
/**
|
||||
* Sometimes this gets changed when the MCPE-layer protocol gets broken to the point where old and new can't
|
||||
* communicate. It's important that we check this to avoid catastrophes.
|
||||
|
@ -27,7 +27,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace pocketmine\network\query;
|
||||
|
||||
use pocketmine\network\AdvancedSourceInterface;
|
||||
use pocketmine\network\AdvancedNetworkInterface;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Binary;
|
||||
|
||||
@ -79,7 +79,7 @@ class QueryHandler{
|
||||
return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4));
|
||||
}
|
||||
|
||||
public function handle(AdvancedSourceInterface $interface, string $address, int $port, string $packet) : void{
|
||||
public function handle(AdvancedNetworkInterface $interface, string $address, int $port, string $packet) : void{
|
||||
$offset = 2;
|
||||
$packetType = ord($packet{$offset++});
|
||||
$sessionID = Binary::readInt(substr($packet, $offset, 4));
|
||||
|
Reference in New Issue
Block a user