Get the current logged in user.

@param \Ratchet\ConnectionInterface $connection
@return mixed
967868
protected function getUser(Connection $connection)
    {
        $recaller = $connection->WebSocket->request->getCookie(Auth::getRecallerName());
        
        if (! $recaller) {
            return false;
        }
        
        try {
            $recaller = $this->Encrypter->decrypt(urldecode($recaller));
        } catch (Exception $e) {
            $recaller = $this->Encrypter->decrypt($recaller);
        }
        
        $id = explode('|', $recaller, 2)[0];
        $model = $this->getUserModel();
        
        return $model::find($id) !== null ? $id : false;
    }
409773
public function getPresenceVerifierFor($connection)
    {
        return tap($this->getPresenceVerifier(), function ($verifier) use ($connection) {
            $verifier->setConnection($connection);
        });
    }
1098319
protected function prepare( Connection $connection )
	{
		$connection->setFetchMode( Config::get( 'database.fetch' ) );

		// Here we'll set a reconnector callback. This reconnector can be any callable
		// so we will set a Closure to reconnect from this manager with the name of
		// the connection, which will allow us to reconnect from the connections.
		$connection->setReconnector( function ( $connection )
		{
			$this->reconnect( $connection->getName() );
		} );

		return $connection;
	}
166668
protected function getSessionIdFromCookie(Connection $connection)
    {
        $cookie = urldecode($connection->WebSocket->request->getCookie(config('session.cookie')));
        
        return $cookie ? Crypt::decrypt($cookie) : null;
    }
945010
protected function prepare(Connection $connection)
	{
		$connection->setFetchMode($this->app['config']['database.fetch']);

		if ($this->app->bound('events'))
		{
			$connection->setEventDispatcher($this->app['events']);
		}

		// Here we'll set a reconnector callback. This reconnector can be any callable
		// so we will set a Closure to reconnect from this manager with the name of
		// the connection, which will allow us to reconnect from the connections.
		$connection->setReconnector(function($connection)
		{
			$this->reconnect($connection->getName());
		});

		return $connection;
	}
1180087
protected function getReadStream(ConnectionInterface $connection)
    {
        $read = new ReadStream();
        $this->addLogging($read, $connection);
        $read->on('invalid', $this->getOutputLogCallback($connection, 'notice', 'Parser unable to parse line: '));
        return $read;
    }
1096791
public function getCurrentUser() {
    if (empty($this->currentUser)) {
      $this->currentUser = \Drupal::service('current_user');
    }
    return $this->currentUser;
  }
1339400
public function connection($connection)
	{
		$connections = Config::get('database.connections');

		$default = Config::get('database.default');

		$connection = $connections[$default];

		$connectionString = "{$connection['driver']}:host={$connection['host']};dbname={$connection['database']}";

		try 
		{
			$pdo = new PDO($connectionString, $connection['username'], $connection['password']);
		}
		catch (PDOException $e)
		{
			print "Error!: " . $e->getMessage() . "<br/>";
			die();
		}

		$db = new Qlake\Database\Query(new Qlake\Database\Connection($pdo), new Qlake\Database\Grammar);

		return $db;
	}
98116
public static function selectOne(Connection $connection)
    {
        $selector = new EntitySelector(AbstractSelector::fromConnection($connection, static::$table, static::$types), get_called_class());

        return $selector->one();
    }
600361
protected function dispatchPendingEvents(ConnectionInterface $connection)
    {
        $connectionId = $connection->getName();
        $consumingEvents = $this->pendingEvents[$connectionId];

        unset($this->pendingEvents[$connectionId]);

        foreach ($consumingEvents as $transactionsEvents) {
            foreach ($transactionsEvents as $transactionEvents) {
                foreach ($transactionEvents as $event) {
                    $this->dispatcher->dispatch($event['event'], $event['payload']);
                }
            }
        }
    }
800097
public function fetchObject($connection, $cursor)
    {
        $result = $this->fetchAssoc($connection, $cursor);
        return $result ? (object)$result : false;
    }
639478
protected function getToken(ConnectionInterface $connection)
    {
        $token = null;

        if (isset($connection->Session) && $connection->Session) {
            foreach ($this->firewalls as $firewall) {
                if (false !== $serializedToken = $connection->Session->get('_security_'.$firewall, false)) {
                    /** @var TokenInterface $token */
                    $token = unserialize($serializedToken);

                    break;
                }
            }
        }

        if (null === $token) {
            $token = new AnonymousToken($this->firewalls[0], 'anon-'.$connection->WAMP->sessionId);
        }

        return $token;
    }
538091
public function findByConnection($connection)
    {
        return $this->first(function ($client, $key) use ($connection) {
            return $client->connection === $connection;
        });
    }
360913
protected function getSecureConnector($connection)
    {
        if (!$this->secureConnector) {
            $loop = $this->getLoop();
            $connector = new \React\Socket\Connector(
                $loop,
                [
                    'dns' => $this->getResolver(),
                ]
            );
            $this->secureConnector = new \React\Socket\SecureConnector($connector, $loop, $this->getSecureContext($connection));
        }
        return $this->secureConnector;
    }
1044625
protected function getWriteStream(ConnectionInterface $connection)
    {
        $write = new WriteStream();
        $this->addLogging($write, $connection);
        return $write;
    }
1042360
protected function getLoggedInUser()
    {
        if (!$this->user) {
            $this->user = $this->app->make(User::class);
        }

        return $this->user;
    }
56681
public function getConnection($connection, $server = null)
    {
        $connectionKey = $this->credentials->sanitizeConnection($connection, $server);
        $handle = $connectionKey->toHandle();

        $connections = $this->getConnections();
        if (!$connections->has($handle)) {
            throw new ConnectionException('Invalid connection: '.$handle);
        }

        return $connections[$handle];
    }