Rename SourceInterface -> NetworkInterface

SourceInterface doesn't make sense really...
This commit is contained in:
Dylan K. Taylor
2018-07-18 11:03:21 +01:00
parent 965f0d670d
commit 4d1e2d1b3a
10 changed files with 45 additions and 45 deletions

View File

@ -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.

View File

@ -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]);
}

View File

@ -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.

View File

@ -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.

View File

@ -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));