Skip to content

Commit

Permalink
CS FIXER
Browse files Browse the repository at this point in the history
  • Loading branch information
prophet777 committed Jul 4, 2015
1 parent 45b2c4f commit 49b1851
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
3 changes: 1 addition & 2 deletions Client/Auth/WebsocketAuthenticationProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Gos\Bundle\WebSocketBundle\Client\Auth;


use Ratchet\ConnectionInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

Expand All @@ -14,4 +13,4 @@ interface WebsocketAuthenticationProviderInterface
* @return TokenInterface
*/
public function authenticate(ConnectionInterface $conn);
}
}
31 changes: 16 additions & 15 deletions Client/ClientManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,31 @@ public function getClient(ConnectionInterface $connection)
{
$storageId = $this->clientStorage->getStorageId($connection);

try{
try {
return $this->clientStorage->getClient($storageId);
} catch (ClientNotFoundException $e) { //User is gone due to ttl
$this->authenticationProvider->authenticate($connection);

return $this->getClient($connection);
}
}

/**
* @param Topic $topic
* @param string $username
* @param Topic $topic
* @param string $username
*
* @return false|string|\Symfony\Component\Security\Core\User\UserInterface
*/
public function findByUsername(Topic $topic, $username)
{
foreach($topic as $connection){
foreach ($topic as $connection) {
$client = $this->getClient($connection);

if($client instanceof AnonymousToken || false === $client){
if ($client instanceof AnonymousToken || false === $client) {
continue;
}

if($client->getUsername() === $username){
if ($client->getUsername() === $username) {
return ['client' => $client, 'connection' => $connection];
}
}
Expand All @@ -81,16 +82,16 @@ public function getAll(Topic $topic, $anonymous = false)
{
$results = [];

foreach($topic as $connection){
foreach ($topic as $connection) {
$client = $this->getClient($connection);

if(true !== $anonymous && ($client instanceof AnonymousToken || false === $client)){
if (true !== $anonymous && ($client instanceof AnonymousToken || false === $client)) {
continue;
}

$results[] = [
'client' => $client,
'connection' => $connection
'connection' => $connection,
];
}

Expand All @@ -107,18 +108,18 @@ public function findByRoles(Topic $topic, array $roles)
{
$results = [];

foreach($topic as $connection){
foreach ($topic as $connection) {
$client = $this->getClient($connection);

if($client instanceof AnonymousToken || false === $client){
if ($client instanceof AnonymousToken || false === $client) {
continue;
}

foreach($client->getRoles() as $role){
if(in_array($role, $roles)){
foreach ($client->getRoles() as $role) {
if (in_array($role, $roles)) {
$results[] = [
'client' => $client,
'connection' => $connection
'connection' => $connection,
];

continue 1;
Expand All @@ -128,4 +129,4 @@ public function findByRoles(Topic $topic, array $roles)

return empty($results) ? false : $results;
}
}
}
7 changes: 3 additions & 4 deletions Client/ClientManipulatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Ratchet\ConnectionInterface;
use Ratchet\Wamp\Topic;
use Symfony\Component\Security\Core\User\UserInterface;

interface ClientManipulatorInterface
{
Expand All @@ -16,8 +15,8 @@ interface ClientManipulatorInterface
public function getClient(ConnectionInterface $connection);

/**
* @param Topic $topic
* @param string $username
* @param Topic $topic
* @param string $username
*
* @return array|false
*/
Expand All @@ -38,4 +37,4 @@ public function findByRoles(Topic $topic, array $roles);
* @return array|false
*/
public function getAll(Topic $topic, $anonymous = false);
}
}
1 change: 1 addition & 0 deletions Client/WebSocketUserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ trait WebSocketUserTrait
public function getCurrentUser(ConnectionInterface $connection)
{
@trigger_error('User ClientManipulator service instead, will be remove in 2.0', E_USER_DEPRECATED);

return $this->clientStorage->getClient($this->clientStorage->getStorageId($connection));
}
}
2 changes: 1 addition & 1 deletion Server/App/WampApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function onOpen(ConnectionInterface $conn)
*/
public function onClose(ConnectionInterface $conn)
{
foreach($conn->WAMP->subscriptions as $topic){
foreach ($conn->WAMP->subscriptions as $topic) {
$wampRequest = $this->wampRouter->match($topic);
$this->topicDispatcher->onUnSubscribe($conn, $topic, $wampRequest);
}
Expand Down

0 comments on commit 49b1851

Please sign in to comment.