@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * @param $request |
| 23 | 23 | * @param ConnectionInterface $from |
| 24 | - * @param $error |
|
| 24 | + * @param string $error |
|
| 25 | 25 | * @throws WebSocketException |
| 26 | 26 | */ |
| 27 | 27 | function error($request,ConnectionInterface $from, $error) |
@@ -101,6 +101,9 @@ discard block |
||
| 101 | 101 | ]; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | + /** |
|
| 105 | + * @param integer $user_id |
|
| 106 | + */ |
|
| 104 | 107 | function isOnline($user_id) |
| 105 | 108 | { |
| 106 | 109 | if(array_key_exists($user_id,$this->userAuthSocketMapper)) |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | * @param $error |
| 25 | 25 | * @throws WebSocketException |
| 26 | 26 | */ |
| 27 | - function error($request,ConnectionInterface $from, $error) |
|
| 27 | + function error($request, ConnectionInterface $from, $error) |
|
| 28 | 28 | { |
| 29 | - if(env('APP_DEBUG')) |
|
| 29 | + if (env('APP_DEBUG')) |
|
| 30 | 30 | { |
| 31 | 31 | echo 'User error: '; |
| 32 | 32 | echo $error."\n"; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | 'event'=>'error', |
| 39 | 39 | 'message'=>$error |
| 40 | 40 | ]; |
| 41 | - $this->sendToWebSocketUser($from,$data); |
|
| 41 | + $this->sendToWebSocketUser($from, $data); |
|
| 42 | 42 | throw new WebSocketException(); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | * @param ConnectionInterface $conn |
| 47 | 47 | * @param $data |
| 48 | 48 | */ |
| 49 | - function sendToWebSocketUser(ConnectionInterface $conn,$data) |
|
| 49 | + function sendToWebSocketUser(ConnectionInterface $conn, $data) |
|
| 50 | 50 | { |
| 51 | - if(!is_array($data)) |
|
| 52 | - $data = ['msg'=>$data,'event'=>'default']; |
|
| 51 | + if (!is_array($data)) |
|
| 52 | + $data = ['msg'=>$data, 'event'=>'default']; |
|
| 53 | 53 | |
| 54 | - if(!isset($data['event'])) |
|
| 54 | + if (!isset($data['event'])) |
|
| 55 | 55 | { |
| 56 | 56 | $data['event'] = 'default'; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if(isset($this->route) && !array_key_exists('sender',$data)) |
|
| 59 | + if (isset($this->route) && !array_key_exists('sender', $data)) |
|
| 60 | 60 | $data['sender'] = $this->getSenderData(); |
| 61 | 61 | |
| 62 | 62 | $conn->send(json_encode($data)); |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * @param array $data |
| 68 | 68 | * @return bool |
| 69 | 69 | */ |
| 70 | - function sendToUser($user_id,$data) |
|
| 70 | + function sendToUser($user_id, $data) |
|
| 71 | 71 | { |
| 72 | - if(!$this->isOnline($user_id)) |
|
| 72 | + if (!$this->isOnline($user_id)) |
|
| 73 | 73 | { |
| 74 | 74 | return false; |
| 75 | 75 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $resourceId = $this->userAuthSocketMapper[$user_id]; |
| 78 | 78 | /** @var ConnectionInterface $conn */ |
| 79 | 79 | $conn = $this->clients[$resourceId]->conn; |
| 80 | - $this->sendToWebSocketUser($conn,$data); |
|
| 80 | + $this->sendToWebSocketUser($conn, $data); |
|
| 81 | 81 | return true; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | function sendBack($data) |
| 88 | 88 | { |
| 89 | - $this->sendToWebSocketUser($this->conn,$data); |
|
| 89 | + $this->sendToWebSocketUser($this->conn, $data); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | function isOnline($user_id) |
| 105 | 105 | { |
| 106 | - if(array_key_exists($user_id,$this->userAuthSocketMapper)) |
|
| 106 | + if (array_key_exists($user_id, $this->userAuthSocketMapper)) |
|
| 107 | 107 | { |
| 108 | 108 | return true; |
| 109 | 109 | } |