@@ -8,13 +8,13 @@ |
||
8 | 8 | unset($items['session']); |
9 | 9 | parent::__construct($items); |
10 | 10 | |
11 | - $this->put('route',$this->get('route')); |
|
11 | + $this->put('route', $this->get('route')); |
|
12 | 12 | $this->forget('route'); |
13 | 13 | } |
14 | 14 | |
15 | 15 | public function __get($property) |
16 | 16 | { |
17 | - if($this->has($property)) |
|
17 | + if ($this->has($property)) |
|
18 | 18 | return $this->get($property); |
19 | 19 | |
20 | 20 | return Parent::get($property); |
@@ -14,8 +14,9 @@ |
||
14 | 14 | |
15 | 15 | public function __get($property) |
16 | 16 | { |
17 | - if($this->has($property)) |
|
18 | - return $this->get($property); |
|
17 | + if($this->has($property)) { |
|
18 | + return $this->get($property); |
|
19 | + } |
|
19 | 20 | |
20 | 21 | return Parent::get($property); |
21 | 22 | } |
@@ -51,10 +51,10 @@ |
||
51 | 51 | new Receiver() |
52 | 52 | ) |
53 | 53 | ), |
54 | - env('WEBSOCKET_PORT',9090) |
|
54 | + env('WEBSOCKET_PORT', 9090) |
|
55 | 55 | ); |
56 | 56 | |
57 | - $this->info('Websocket is now running at port '.env('WEBSOCKET_PORT',9090)); |
|
57 | + $this->info('Websocket is now running at port '.env('WEBSOCKET_PORT', 9090)); |
|
58 | 58 | $server->run(); |
59 | 59 | } |
60 | 60 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->userAuthSocketMapper = []; |
48 | 48 | |
49 | 49 | $this->mainRoutes(); |
50 | - include base_path() . '/routes/websocket.php'; |
|
50 | + include base_path().'/routes/websocket.php'; |
|
51 | 51 | $this->routes = WsRoute::getRoutes(); |
52 | 52 | } |
53 | 53 | |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function onMessage(ConnectionInterface $from, $msg) |
69 | 69 | { |
70 | - $msg = json_decode($msg,true); |
|
71 | - $this->callRoute($from,$msg); |
|
70 | + $msg = json_decode($msg, true); |
|
71 | + $this->callRoute($from, $msg); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | function callRoute(ConnectionInterface $from, $msg) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $this->resetSession($msg['session']); |
80 | 80 | |
81 | - $this->resetAuth($msg,$from); |
|
81 | + $this->resetAuth($msg, $from); |
|
82 | 82 | |
83 | 83 | $route = $this->routes[$msg['route']]; |
84 | 84 | |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | $routesToCall = $client->onCloseRoutes; |
122 | 122 | foreach ($routesToCall as $route) |
123 | 123 | { |
124 | - $msg = ['session'=>$client->session,'route'=>$route]; |
|
125 | - $this->callRoute($conn,$msg); |
|
124 | + $msg = ['session'=>$client->session, 'route'=>$route]; |
|
125 | + $this->callRoute($conn, $msg); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | unset($this->clients[$conn->resourceId]); |
129 | - unset($this->userAuthSocketMapper[array_search($conn->resourceId,$this->userAuthSocketMapper)]); |
|
129 | + unset($this->userAuthSocketMapper[array_search($conn->resourceId, $this->userAuthSocketMapper)]); |
|
130 | 130 | |
131 | 131 | echo "Connection {$conn->resourceId} has disconnected\n"; |
132 | 132 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ($data = \Session::getHandler()->read($session_id)) { |
194 | 194 | $data = @unserialize($data); |
195 | 195 | |
196 | - if ($data !== false && ! is_null($data) && is_array($data)) { |
|
196 | + if ($data !== false && !is_null($data) && is_array($data)) { |
|
197 | 197 | return $data; |
198 | 198 | } |
199 | 199 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | function getUserModel() |
210 | 210 | { |
211 | - return \Config::get('laravel-ratchet.userModelNamespace','App\Entities\Users\User'); |
|
211 | + return \Config::get('laravel-ratchet.userModelNamespace', 'App\Entities\Users\User'); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | function resetSession($session_id) |
@@ -225,15 +225,15 @@ discard block |
||
225 | 225 | * @param ConnectionInterface $from |
226 | 226 | * @throws WebSocketException |
227 | 227 | */ |
228 | - function resetAuth($msg,$from) |
|
228 | + function resetAuth($msg, $from) |
|
229 | 229 | { |
230 | 230 | $data = $this->readFromHandler($msg['session']); |
231 | 231 | |
232 | - if(!empty($data)) |
|
232 | + if (!empty($data)) |
|
233 | 233 | { |
234 | 234 | $user_id = $this->getUserId($data); |
235 | 235 | $user = $this->getUserModel()::find($user_id); |
236 | - if(!$user) |
|
236 | + if (!$user) |
|
237 | 237 | { |
238 | 238 | $this->error($msg, $from, 'There is no such user.'); |
239 | 239 | } |
@@ -242,8 +242,7 @@ |
||
242 | 242 | $this->clients[$from->resourceId]->id = \Auth::id(); |
243 | 243 | $this->clients[$from->resourceId]->session = $msg['session']; |
244 | 244 | $this->userAuthSocketMapper[\Auth::id()] = $from->resourceId; |
245 | - } |
|
246 | - else |
|
245 | + } else |
|
247 | 246 | { |
248 | 247 | $this->error($msg, $from, 'Unauthenticated.'); |
249 | 248 | } |