@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | /** |
128 | 128 | * @param $msg |
129 | - * @param $from |
|
129 | + * @param ConnectionInterface $from |
|
130 | 130 | * @throws WebSocketException |
131 | 131 | */ |
132 | 132 | function checkForRequiredInMessage($msg,$from) |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | - * @param $clonedObject |
|
144 | + * @param Receiver $clonedObject |
|
145 | 145 | * @param $clone |
146 | 146 | */ |
147 | 147 | function cloneProperties($clonedObject, $clone) |
@@ -13,7 +13,6 @@ |
||
13 | 13 | use Shamaseen\Laravel\Ratchet\Exceptions\WebSocketException; |
14 | 14 | use Shamaseen\Laravel\Ratchet\Facades\WsRoute; |
15 | 15 | use Shamaseen\Laravel\Ratchet\Objects\Clients\Client; |
16 | -use Shamaseen\Laravel\Ratchet\Routes\Routes; |
|
17 | 16 | use Ratchet\ConnectionInterface; |
18 | 17 | use Ratchet\MessageComponentInterface; |
19 | 18 | use Shamaseen\Laravel\Ratchet\Traits\WebSocketMessagesManager; |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | { |
71 | 71 | $msg = json_decode($msg); |
72 | 72 | |
73 | - $this->checkForRequiredInMessage($msg,$from); |
|
73 | + $this->checkForRequiredInMessage($msg, $from); |
|
74 | 74 | |
75 | 75 | \Session::setId($msg->session); |
76 | 76 | |
77 | 77 | \Session::start(); |
78 | 78 | |
79 | - if($this->routes[$msg->route]->auth && !\Auth::check()) |
|
80 | - $this->error($msg,$from,'Unauthenticated.'); |
|
79 | + if ($this->routes[$msg->route]->auth && !\Auth::check()) |
|
80 | + $this->error($msg, $from, 'Unauthenticated.'); |
|
81 | 81 | else |
82 | 82 | $this->userAuthSocketMapper[\Auth::id()] = $from->resourceId; |
83 | 83 | |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | $method = $this->routes[$msg->route]->method; |
86 | 86 | $controller = new $class; |
87 | 87 | |
88 | - $this->cloneProperties($this,$controller); |
|
88 | + $this->cloneProperties($this, $controller); |
|
89 | 89 | |
90 | 90 | $controller->conn = $from; |
91 | 91 | |
92 | - if(!method_exists($controller,$method)) |
|
92 | + if (!method_exists($controller, $method)) |
|
93 | 93 | { |
94 | - $this->error($msg,$from,'Method doesnt\'t exist !'); |
|
94 | + $this->error($msg, $from, 'Method doesnt\'t exist !'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $controller->$method($msg); |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | * @param $from |
130 | 130 | * @throws WebSocketException |
131 | 131 | */ |
132 | - function checkForRequiredInMessage($msg,$from) |
|
132 | + function checkForRequiredInMessage($msg, $from) |
|
133 | 133 | { |
134 | - if(!isset($msg->route) || !isset($msg->session)) |
|
134 | + if (!isset($msg->route) || !isset($msg->session)) |
|
135 | 135 | { |
136 | - $this->error($msg,$from,'You can\'t send a request without the route and the session id !'); |
|
136 | + $this->error($msg, $from, 'You can\'t send a request without the route and the session id !'); |
|
137 | 137 | } |
138 | 138 | |
139 | - if(!isset($this->routes[$msg->route])) |
|
140 | - $this->error($msg,$from,'No such route !'); |
|
139 | + if (!isset($this->routes[$msg->route])) |
|
140 | + $this->error($msg, $from, 'No such route !'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -76,10 +76,11 @@ discard block |
||
76 | 76 | |
77 | 77 | \Session::start(); |
78 | 78 | |
79 | - if($this->routes[$msg->route]->auth && !\Auth::check()) |
|
80 | - $this->error($msg,$from,'Unauthenticated.'); |
|
81 | - else |
|
82 | - $this->userAuthSocketMapper[\Auth::id()] = $from->resourceId; |
|
79 | + if($this->routes[$msg->route]->auth && !\Auth::check()) { |
|
80 | + $this->error($msg,$from,'Unauthenticated.'); |
|
81 | + } else { |
|
82 | + $this->userAuthSocketMapper[\Auth::id()] = $from->resourceId; |
|
83 | + } |
|
83 | 84 | |
84 | 85 | $class = $this->routes[$msg->route]->controller; |
85 | 86 | $method = $this->routes[$msg->route]->method; |
@@ -95,8 +96,7 @@ discard block |
||
95 | 96 | } |
96 | 97 | |
97 | 98 | $controller->$method($msg); |
98 | - } |
|
99 | - catch (WebSocketException $exception) |
|
99 | + } catch (WebSocketException $exception) |
|
100 | 100 | { |
101 | 101 | |
102 | 102 | } |
@@ -136,8 +136,9 @@ discard block |
||
136 | 136 | $this->error($msg,$from,'You can\'t send a request without the route and the session id !'); |
137 | 137 | } |
138 | 138 | |
139 | - if(!isset($this->routes[$msg->route])) |
|
140 | - $this->error($msg,$from,'No such route !'); |
|
139 | + if(!isset($this->routes[$msg->route])) { |
|
140 | + $this->error($msg,$from,'No such route !'); |
|
141 | + } |
|
141 | 142 | } |
142 | 143 | |
143 | 144 | /** |
@@ -24,9 +24,9 @@ |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | - * @param $routeName |
|
28 | - * @param $controller |
|
29 | - * @param $method |
|
27 | + * @param string $routeName |
|
28 | + * @param string $controller |
|
29 | + * @param string $method |
|
30 | 30 | * @param bool $authenticated |
31 | 31 | */ |
32 | 32 | function make($routeName, $controller, $method,$authenticated = true) |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | function mainRoutes() |
22 | 22 | { |
23 | - $this->make('initializeWebsocket','Shamaseen\Laravel\Ratchet\Controllers\InitializeController','index'); |
|
23 | + $this->make('initializeWebsocket', 'Shamaseen\Laravel\Ratchet\Controllers\InitializeController', 'index'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param $method |
30 | 30 | * @param bool $authenticated |
31 | 31 | */ |
32 | - function make($routeName, $controller, $method,$authenticated = true) |
|
32 | + function make($routeName, $controller, $method, $authenticated = true) |
|
33 | 33 | { |
34 | 34 | $this->routes[$routeName] = (object) [ |
35 | 35 | 'controller'=>$controller, |
@@ -21,7 +21,7 @@ |
||
21 | 21 | /** |
22 | 22 | * @param $msg |
23 | 23 | * @param $from |
24 | - * @param $error |
|
24 | + * @param string $error |
|
25 | 25 | * @throws WebSocketException |
26 | 26 | */ |
27 | 27 | function error($msg,ConnectionInterface $from, $error) |
@@ -63,7 +63,7 @@ |
||
63 | 63 | */ |
64 | 64 | function sendBack($data) |
65 | 65 | { |
66 | - $this->sendToWebSocketUser($this->conn,$data); |
|
66 | + $this->sendToWebSocketUser($this->conn,$data); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
70 | 70 | \ No newline at end of file |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @param $error |
25 | 25 | * @throws WebSocketException |
26 | 26 | */ |
27 | - function error($msg,ConnectionInterface $from, $error) |
|
27 | + function error($msg, ConnectionInterface $from, $error) |
|
28 | 28 | { |
29 | 29 | echo 'Error: '; |
30 | 30 | echo $error."\n"; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | 'type'=>'error', |
34 | 34 | 'message'=>$error |
35 | 35 | ]; |
36 | - $this->sendToWebSocketUser($from,$data); |
|
36 | + $this->sendToWebSocketUser($from, $data); |
|
37 | 37 | throw new WebSocketException(); |
38 | 38 | } |
39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param ConnectionInterface $conn |
42 | 42 | * @param $data |
43 | 43 | */ |
44 | - function sendToWebSocketUser(ConnectionInterface $conn,$data) |
|
44 | + function sendToWebSocketUser(ConnectionInterface $conn, $data) |
|
45 | 45 | { |
46 | 46 | $conn->send(json_encode($data)); |
47 | 47 | } |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | * @param int $user_id |
51 | 51 | * @param array $data |
52 | 52 | */ |
53 | - function sendToUser($user_id,$data) |
|
53 | + function sendToUser($user_id, $data) |
|
54 | 54 | { |
55 | 55 | $resourceId = $this->userAuthSocketMapper[$user_id]; |
56 | 56 | /** @var ConnectionInterface $conn */ |
57 | 57 | $conn = $this->clients[$resourceId]->conn; |
58 | - $this->sendToWebSocketUser($conn,$data); |
|
58 | + $this->sendToWebSocketUser($conn, $data); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | function sendBack($data) |
65 | 65 | { |
66 | - $this->sendToWebSocketUser($this->conn,$data); |
|
66 | + $this->sendToWebSocketUser($this->conn, $data); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
70 | 70 | \ No newline at end of file |
@@ -53,7 +53,7 @@ |
||
53 | 53 | new Receiver() |
54 | 54 | ) |
55 | 55 | ), |
56 | - env('CHAT_PORT',8080) |
|
56 | + env('CHAT_PORT', 8080) |
|
57 | 57 | ); |
58 | 58 | |
59 | 59 | $server->run(); |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | class WsRoute extends \Illuminate\Support\Facades\Facade |
12 | 12 | { |
13 | - static function getFacadeAccessor(){ |
|
13 | + static function getFacadeAccessor() { |
|
14 | 14 | |
15 | 15 | return 'WsRoute'; |
16 | 16 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->publishes([ |
29 | 29 | __DIR__.'/config' => realpath('config'), |
30 | 30 | __DIR__.'/Routes/websocket' => realpath('routes'), |
31 | - ],'laravel-ratchet'); |
|
31 | + ], 'laravel-ratchet'); |
|
32 | 32 | |
33 | 33 | if ($this->app['config']->get('laravel-ratchet') === null) { |
34 | 34 | $this->app['config']->set('laravel-ratchet', require __DIR__.'/config/laravel-ratchet.php'); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function register() |
44 | 44 | { |
45 | - $this->app->bind('WsRoute',function (){ |
|
45 | + $this->app->bind('WsRoute', function() { |
|
46 | 46 | return new Routes(); |
47 | 47 | }); |
48 | 48 | } |