Added NetworkSession->sendEncoded(), clean up some code

This commit is contained in:
Dylan K. Taylor 2018-07-27 18:39:14 +01:00
parent 2647b3f404
commit bdd42d6a78
4 changed files with 8 additions and 3 deletions

View File

@ -908,7 +908,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->usedChunks[Level::chunkHash($x, $z)] = true;
$this->chunkLoadCount++;
$this->networkSession->getInterface()->putPacket($this->networkSession, $payload);
$this->networkSession->sendEncoded($payload);
if($this->spawned){
foreach($this->level->getChunkEntities($x, $z) as $entity){

View File

@ -1903,7 +1903,7 @@ class Server{
public function broadcastPacketsCallback(string $payload, array $sessions, bool $immediate = false){
/** @var NetworkSession $session */
foreach($sessions as $session){
$session->getInterface()->putPacket($session, $payload, $immediate);
$session->sendEncoded($payload, $immediate);
}
}

View File

@ -192,6 +192,11 @@ class NetworkSession{
}
}
public function sendEncoded(string $payload, bool $immediate = false) : void{
//TODO: encryption
$this->interface->putPacket($this, $payload, $immediate);
}
/**
* Disconnects the session, destroying the associated player (if it exists).
*

View File

@ -86,7 +86,7 @@ class PreSpawnSessionHandler extends SessionHandler{
$this->player->sendAllInventories();
$this->player->getInventory()->sendCreativeContents();
$this->player->getInventory()->sendHeldItem($this->player);
$this->session->getInterface()->putPacket($this->session, $this->server->getCraftingManager()->getCraftingDataPacket());
$this->session->sendEncoded($this->server->getCraftingManager()->getCraftingDataPacket());
$this->server->sendFullPlayerListData($this->player);
}