public function __construct(Synapse $server, string $ip, int $port)
 {
     $this->synapse = $server;
     $this->ip = $ip;
     $this->port = $port;
     $this->registerPackets();
     $this->client = new SynapseClient($server->getLogger(), $server->getGenisysServer()->getLoader(), $port, $ip);
 }
Exemplo n.º 2
0
 public function directDataPacket(DataPacket $packet, $needACK = false)
 {
     if ($packet instanceof PlayerListPacket) {
         $pk = new FastPlayerListPacket();
         $pk->sendTo = $this->uuid;
         $pk->type = $packet->type;
         foreach ($packet->entries as $entry) {
             if ($packet->type !== PlayerListPacket::TYPE_REMOVE) {
                 array_pop($entry);
                 array_pop($entry);
             }
             $pk->entries[] = $entry;
         }
         Synapse::getInstance()->sendDataPacket($pk);
         return;
     }
     $this->interface->putPacket($this, $packet, $needACK, true);
 }
Exemplo n.º 3
0
 public function transfer(string $hash)
 {
     $clients = Synapse::getInstance()->getClientData();
     if (isset($clients[$hash])) {
         foreach ($this->getLevel()->getEntities() as $entity) {
             if (isset($entity->hasSpawned[$this->getLoaderId()])) {
                 $entity->despawnFrom($this);
             }
         }
         $pk = new TransferPacket();
         $pk->uuid = $this->uuid;
         $pk->clientHash = $hash;
         Synapse::getInstance()->sendDataPacket($pk);
         /*$ip = $clients[$hash]["ip"];
         			$port = $clients[$hash]["port"];
         
         			$this->close("", "Transferred to $ip:$port");
         			Synapse::getInstance()->removePlayer($this);*/
     }
 }