@@ -44,8 +44,9 @@ |
||
| 44 | 44 | |
| 45 | 45 | function hasMember($client) |
| 46 | 46 | { |
| 47 | - if(array_key_exists($client->id,$this->members)) |
|
| 48 | - return true; |
|
| 47 | + if(array_key_exists($client->id,$this->members)) { |
|
| 48 | + return true; |
|
| 49 | + } |
|
| 49 | 50 | |
| 50 | 51 | return false; |
| 51 | 52 | } |
@@ -46,11 +46,13 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | function sendToWebSocketUser(ConnectionInterface $conn,$data) |
| 48 | 48 | { |
| 49 | - if(!is_array($data)) |
|
| 50 | - $data = ['msg'=>$data]; |
|
| 49 | + if(!is_array($data)) { |
|
| 50 | + $data = ['msg'=>$data]; |
|
| 51 | + } |
|
| 51 | 52 | |
| 52 | - if(isset($this->route) && $this->route->auth && !array_key_exists('sender',$data)) |
|
| 53 | - $data['sender'] = $this->getSenderData(); |
|
| 53 | + if(isset($this->route) && $this->route->auth && !array_key_exists('sender',$data)) { |
|
| 54 | + $data['sender'] = $this->getSenderData(); |
|
| 55 | + } |
|
| 54 | 56 | |
| 55 | 57 | $conn->send(json_encode($data)); |
| 56 | 58 | } |
@@ -78,8 +78,9 @@ |
||
| 78 | 78 | /** @var Room $room */ |
| 79 | 79 | $room = $this->rooms[$room_id]; |
| 80 | 80 | $client = $this->clients[$this->userAuthSocketMapper[\Auth::id()]]; |
| 81 | - if(!$this->hasMember($client)) |
|
| 82 | - $this->error($this->request,$this->conn,'You can\'t send a message to room which you are not in !'); |
|
| 81 | + if(!$this->hasMember($client)) { |
|
| 82 | + $this->error($this->request,$this->conn,'You can\'t send a message to room which you are not in !'); |
|
| 83 | + } |
|
| 83 | 84 | |
| 84 | 85 | foreach ($room->members as $member) |
| 85 | 86 | { |
@@ -79,10 +79,11 @@ discard block |
||
| 79 | 79 | \Session::start(); |
| 80 | 80 | |
| 81 | 81 | $route = $this->routes[$msg->route]; |
| 82 | - if($route->auth && !\Auth::check()) |
|
| 83 | - $this->error($msg,$from,'Unauthenticated.'); |
|
| 84 | - else |
|
| 85 | - $this->userAuthSocketMapper[\Auth::id()] = $from->resourceId; |
|
| 82 | + if($route->auth && !\Auth::check()) { |
|
| 83 | + $this->error($msg,$from,'Unauthenticated.'); |
|
| 84 | + } else { |
|
| 85 | + $this->userAuthSocketMapper[\Auth::id()] = $from->resourceId; |
|
| 86 | + } |
|
| 86 | 87 | |
| 87 | 88 | $class = $route->controller; |
| 88 | 89 | $method = $route->method; |
@@ -101,12 +102,10 @@ discard block |
||
| 101 | 102 | } |
| 102 | 103 | |
| 103 | 104 | $controller->$method(); |
| 104 | - } |
|
| 105 | - catch (WebSocketException $exception) |
|
| 105 | + } catch (WebSocketException $exception) |
|
| 106 | 106 | { |
| 107 | 107 | |
| 108 | - } |
|
| 109 | - catch(ValidationException $exception) |
|
| 108 | + } catch(ValidationException $exception) |
|
| 110 | 109 | { |
| 111 | 110 | $this->sendToWebSocketUser($from,[ |
| 112 | 111 | 'message'=>$exception->getMessage(), |
@@ -150,8 +149,9 @@ discard block |
||
| 150 | 149 | $this->error($msg,$from,'You can\'t send a request without the route and the session id !'); |
| 151 | 150 | } |
| 152 | 151 | |
| 153 | - if(!isset($this->routes[$msg->route])) |
|
| 154 | - $this->error($msg,$from,'No such route !'); |
|
| 152 | + if(!isset($this->routes[$msg->route])) { |
|
| 153 | + $this->error($msg,$from,'No such route !'); |
|
| 154 | + } |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |