Skip to content

Commit 6065748

Browse files
authored
Merge pull request #8 from Askedio/analysis-XpRRjZ
Applied fixes from StyleCI
2 parents 13d2032 + 96ad5c4 commit 6065748

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

src/Console/Commands/RatchetServerCommand.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
use Ratchet\WebSocket\WsServer;
1111
use Symfony\Component\Console\Input\InputOption;
1212

13-
14-
1513
class RatchetServerCommand extends Command
1614
{
1715
/**
@@ -117,8 +115,7 @@ private function getWsServerDriver($ratchetServer)
117115
*/
118116
private function startWampServer()
119117
{
120-
121-
$loop = \React\EventLoop\Factory::create();
118+
$loop = \React\EventLoop\Factory::create();
122119

123120
$class = $this->option('class');
124121

@@ -130,9 +127,9 @@ private function startWampServer()
130127
$pull = $context->getSocket(\ZMQ::SOCKET_PULL);
131128
$pull->bind(sprintf('tcp://%s:%d', config('ratchet.zmq.host'), config('ratchet.zmq.port')));
132129

133-
$pull->on('message', function($message) use ($ratchetServer) {
134-
$ratchetServer->onEntry($message);
135-
});
130+
$pull->on('message', function ($message) use ($ratchetServer) {
131+
$ratchetServer->onEntry($message);
132+
});
136133

137134

138135
$webSock = new \React\Socket\Server($loop);
@@ -160,7 +157,6 @@ private function startWampServer()
160157
*/
161158
private function server($driver)
162159
{
163-
164160
if ($driver == 'WampServer') {
165161
return $this->startWampServer();
166162
}

src/Providers/LaravelRatchetServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function register()
1717
$this->app->register(\GrahamCampbell\Throttle\ThrottleServiceProvider::class);
1818

1919
$this->app->singleton('command.ratchet.serve', function () {
20-
return new RatchetServerCommand();
20+
return new RatchetServerCommand();
2121
});
2222

2323
$this->commands('command.ratchet.serve');

src/Pusher.php

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
use Ratchet\ConnectionInterface;
66
use Ratchet\Wamp\WampServerInterface;
77

8-
class Pusher implements WampServerInterface {
9-
10-
11-
public $subscribedTopics = array();
8+
class Pusher implements WampServerInterface
9+
{
10+
public $subscribedTopics = [];
1211

1312

1413
protected $console = false;
1514

16-
1715
public function __construct($console)
1816
{
1917
$this->console = $console;
@@ -22,7 +20,8 @@ public function __construct($console)
2220
/**
2321
* @param string JSON'ified string we'll receive from ZeroMQ
2422
*/
25-
public function onEntry($entry) {
23+
public function onEntry($entry)
24+
{
2625
$entryData = json_decode($entry, true);
2726

2827
if (!array_key_exists($entryData['category'], $this->subscribedTopics)) {
@@ -40,7 +39,8 @@ public function onEntry($entry) {
4039
* @param \Ratchet\ConnectionInterface $conn
4140
* @param string|Topic $topic The topic to subscribe to
4241
*/
43-
public function onSubscribe(ConnectionInterface $conn, $topic) {
42+
public function onSubscribe(ConnectionInterface $conn, $topic)
43+
{
4444
$this->console->info("onSubscribe: {$conn->WAMP->sessionId} topic: $topic {$topic->count()}");
4545

4646
if (!array_key_exists($topic->getId(), $this->subscribedTopics)) {
@@ -49,14 +49,14 @@ public function onSubscribe(ConnectionInterface $conn, $topic) {
4949
}
5050
}
5151

52-
5352
/**
5453
* A request to unsubscribe from a topic has been made.
5554
*
5655
* @param \Ratchet\ConnectionInterface $conn
5756
* @param string|Topic $topic The topic to unsubscribe from
5857
*/
59-
public function onUnSubscribe(ConnectionInterface $conn, $topic) {
58+
public function onUnSubscribe(ConnectionInterface $conn, $topic)
59+
{
6060
$this->console->info("onUnSubscribe: topic: $topic {$topic->count()}");
6161
}
6262

@@ -67,7 +67,8 @@ public function onUnSubscribe(ConnectionInterface $conn, $topic) {
6767
*
6868
* @throws \Exception
6969
*/
70-
public function onOpen(ConnectionInterface $conn) {
70+
public function onOpen(ConnectionInterface $conn)
71+
{
7172
$this->console->info("onOpen ({$conn->WAMP->sessionId})");
7273
}
7374

@@ -78,11 +79,11 @@ public function onOpen(ConnectionInterface $conn) {
7879
*
7980
* @throws \Exception
8081
*/
81-
public function onClose(ConnectionInterface $conn) {
82+
public function onClose(ConnectionInterface $conn)
83+
{
8284
$this->console->info("onClose ({$conn->WAMP->sessionId})");
8385
}
8486

85-
8687
/**
8788
* An RPC call has been received.
8889
*
@@ -91,12 +92,12 @@ public function onClose(ConnectionInterface $conn) {
9192
* @param string|Topic $topic The topic to execute the call against
9293
* @param array $params Call parameters received from the client
9394
*/
94-
public function onCall(ConnectionInterface $conn, $id, $topic, array $params) {
95-
$this->console->info("onCall");
95+
public function onCall(ConnectionInterface $conn, $id, $topic, array $params)
96+
{
97+
$this->console->info('onCall');
9698
$conn->callError($id, $topic, 'You are not allowed to make calls')->close();
9799
}
98100

99-
100101
/**
101102
* A client is attempting to publish content to a subscribed connections on a URI.
102103
*
@@ -106,8 +107,9 @@ public function onCall(ConnectionInterface $conn, $id, $topic, array $params) {
106107
* @param array $exclude A list of session IDs the message should be excluded from (blacklist)
107108
* @param array $eligible A list of session Ids the message should be send to (whitelist)
108109
*/
109-
public function onPublish(ConnectionInterface $conn, $topic, $event, array $exclude, array $eligible) {
110-
$this->console->info("onPublish");
110+
public function onPublish(ConnectionInterface $conn, $topic, $event, array $exclude, array $eligible)
111+
{
112+
$this->console->info('onPublish');
111113
}
112114

113115
/**
@@ -119,7 +121,8 @@ public function onPublish(ConnectionInterface $conn, $topic, $event, array $excl
119121
*
120122
* @throws \Exception
121123
*/
122-
public function onError(ConnectionInterface $conn, \Exception $e) {
123-
$this->console->info("onError" . $e->getMessage());
124+
public function onError(ConnectionInterface $conn, \Exception $e)
125+
{
126+
$this->console->info('onError'.$e->getMessage());
124127
}
125-
}
128+
}

src/config/ratchet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
],
2222
'abortOnMessageThrottle' => false,
2323
'blackList' => collect([]),
24-
'zmq' => [
24+
'zmq' => [
2525
'host' => '127.0.0.1',
2626
'port' => 5555,
2727
],

0 commit comments

Comments
 (0)