5
5
use Ratchet \ConnectionInterface ;
6
6
use Ratchet \Wamp \WampServerInterface ;
7
7
8
- class Pusher implements WampServerInterface {
9
-
10
-
11
- public $ subscribedTopics = array ();
8
+ class Pusher implements WampServerInterface
9
+ {
10
+ public $ subscribedTopics = [];
12
11
13
12
14
13
protected $ console = false ;
15
14
16
-
17
15
public function __construct ($ console )
18
16
{
19
17
$ this ->console = $ console ;
@@ -22,7 +20,8 @@ public function __construct($console)
22
20
/**
23
21
* @param string JSON'ified string we'll receive from ZeroMQ
24
22
*/
25
- public function onEntry ($ entry ) {
23
+ public function onEntry ($ entry )
24
+ {
26
25
$ entryData = json_decode ($ entry , true );
27
26
28
27
if (!array_key_exists ($ entryData ['category ' ], $ this ->subscribedTopics )) {
@@ -40,7 +39,8 @@ public function onEntry($entry) {
40
39
* @param \Ratchet\ConnectionInterface $conn
41
40
* @param string|Topic $topic The topic to subscribe to
42
41
*/
43
- public function onSubscribe (ConnectionInterface $ conn , $ topic ) {
42
+ public function onSubscribe (ConnectionInterface $ conn , $ topic )
43
+ {
44
44
$ this ->console ->info ("onSubscribe: {$ conn ->WAMP ->sessionId } topic: $ topic {$ topic ->count ()}" );
45
45
46
46
if (!array_key_exists ($ topic ->getId (), $ this ->subscribedTopics )) {
@@ -49,14 +49,14 @@ public function onSubscribe(ConnectionInterface $conn, $topic) {
49
49
}
50
50
}
51
51
52
-
53
52
/**
54
53
* A request to unsubscribe from a topic has been made.
55
54
*
56
55
* @param \Ratchet\ConnectionInterface $conn
57
56
* @param string|Topic $topic The topic to unsubscribe from
58
57
*/
59
- public function onUnSubscribe (ConnectionInterface $ conn , $ topic ) {
58
+ public function onUnSubscribe (ConnectionInterface $ conn , $ topic )
59
+ {
60
60
$ this ->console ->info ("onUnSubscribe: topic: $ topic {$ topic ->count ()}" );
61
61
}
62
62
@@ -67,7 +67,8 @@ public function onUnSubscribe(ConnectionInterface $conn, $topic) {
67
67
*
68
68
* @throws \Exception
69
69
*/
70
- public function onOpen (ConnectionInterface $ conn ) {
70
+ public function onOpen (ConnectionInterface $ conn )
71
+ {
71
72
$ this ->console ->info ("onOpen ( {$ conn ->WAMP ->sessionId }) " );
72
73
}
73
74
@@ -78,11 +79,11 @@ public function onOpen(ConnectionInterface $conn) {
78
79
*
79
80
* @throws \Exception
80
81
*/
81
- public function onClose (ConnectionInterface $ conn ) {
82
+ public function onClose (ConnectionInterface $ conn )
83
+ {
82
84
$ this ->console ->info ("onClose ( {$ conn ->WAMP ->sessionId }) " );
83
85
}
84
86
85
-
86
87
/**
87
88
* An RPC call has been received.
88
89
*
@@ -91,12 +92,12 @@ public function onClose(ConnectionInterface $conn) {
91
92
* @param string|Topic $topic The topic to execute the call against
92
93
* @param array $params Call parameters received from the client
93
94
*/
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 ' );
96
98
$ conn ->callError ($ id , $ topic , 'You are not allowed to make calls ' )->close ();
97
99
}
98
100
99
-
100
101
/**
101
102
* A client is attempting to publish content to a subscribed connections on a URI.
102
103
*
@@ -106,8 +107,9 @@ public function onCall(ConnectionInterface $conn, $id, $topic, array $params) {
106
107
* @param array $exclude A list of session IDs the message should be excluded from (blacklist)
107
108
* @param array $eligible A list of session Ids the message should be send to (whitelist)
108
109
*/
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 ' );
111
113
}
112
114
113
115
/**
@@ -119,7 +121,8 @@ public function onPublish(ConnectionInterface $conn, $topic, $event, array $excl
119
121
*
120
122
* @throws \Exception
121
123
*/
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 ());
124
127
}
125
- }
128
+ }
0 commit comments