public function onConnection(AuthClient $connection)
    {
        //bubble the events up
        $connection->on('login_success', function(AuthClient $client, DisconnectPacket $packet) {
            $this->emit('login_success', [$client->getUsername(), $client->getUUID(), $packet]);
        });

        $connection->on('status_request', function(StatusResponsePacket $packet) {
            $this->emit('status_request', [$packet]);
        });

        $connection->on('close', function() use (&$connection) {
            $amount = count($this->clients);
            for($i = 0; $i<$amount; $i++) {
                /** @var $checkclient AuthClient */
                $checkclient = $this->clients[$i];
                //if we found our connection
                if($checkclient === $connection) {
                    //remove from array and reset the keys
                    unset($this->clients[$i]);
                    $this->clients = array_values($this->clients);
                    echo "A client disconnected. Now there are total ". ($amount - 1) . " clients.\n";
                    $this->emit('disconnect', []);
                    return;
                }
            }
        });

        //if there is an error with the connection echo the error and end the connection
        $connection->on('error', function($error, Connection $connection) {
            echo "ERROR: $error\n";
            $connection->end();
        });

        //add the connection to the list of tracked connections
        $this->clients[] = $connection;

        //echo how many are now online
        $count = count($this->clients);
        echo "New client conected: {$connection->getRemoteAddress()}. Clients online: $count.\n";
    }