disconnect() public method

public disconnect ( $socket )
Example #1
0
 public function disconnect($socket)
 {
     $id = $this->players->delPlayer($socket);
     // a player disconnected so send to all
     $this->sendToAll($socket, Commands::PLAYER_DISCONNECT . $this->commandee->setPlayer($id));
     $map_id = $this->maps->getMapByPlayerId($id);
     if ($map_id !== NULL) {
         $map_id = $map_id->getId();
         // the map's other player state goes to free and send him to a game over message
         $other_player = $this->maps->getMap($map_id)->getOtherPlayer($id);
         $this->players->getPlayer($other_player)->setState(\Entity\States::FREE);
         $this->sendToOne($this->players->getSocketById($other_player), Commands::GAME_OVER . Commandee::NO_ID);
         $this->maps->delMap($map_id);
     }
     parent::disconnect($socket);
 }