@@ -104,12 +104,13 @@ public function publish(string $appId, string $channel, stdClass $payload): bool
104
104
105
105
$ payload = json_encode ($ payload );
106
106
107
- $ this ->publishClient ->__call ('publish ' , ["$ appId: $ channel " , $ payload ]);
107
+ $ this ->publishClient ->__call ('publish ' , ["{ $ appId} : { $ channel} " , $ payload ]);
108
108
109
109
DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATOR_MESSAGE_PUBLISHED , [
110
110
'channel ' => $ channel ,
111
111
'serverId ' => $ this ->getServerId (),
112
112
'payload ' => $ payload ,
113
+ 'pubsub ' => "{$ appId }: {$ channel }" ,
113
114
]);
114
115
115
116
return true ;
@@ -124,18 +125,19 @@ public function publish(string $appId, string $channel, stdClass $payload): bool
124
125
*/
125
126
public function subscribe (string $ appId , string $ channel ): bool
126
127
{
127
- if (! isset ($ this ->subscribedChannels ["$ appId: $ channel " ])) {
128
+ if (! isset ($ this ->subscribedChannels ["{ $ appId} : { $ channel} " ])) {
128
129
// We're not subscribed to the channel yet, subscribe and set the count to 1
129
- $ this ->subscribeClient ->__call ('subscribe ' , ["$ appId: $ channel " ]);
130
- $ this ->subscribedChannels ["$ appId: $ channel " ] = 1 ;
130
+ $ this ->subscribeClient ->__call ('subscribe ' , ["{ $ appId} : { $ channel} " ]);
131
+ $ this ->subscribedChannels ["{ $ appId} : { $ channel} " ] = 1 ;
131
132
} else {
132
133
// Increment the subscribe count if we've already subscribed
133
- $ this ->subscribedChannels ["$ appId: $ channel " ]++;
134
+ $ this ->subscribedChannels ["{ $ appId} : { $ channel} " ]++;
134
135
}
135
136
136
137
DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATOR_SUBSCRIBED , [
137
138
'channel ' => $ channel ,
138
139
'serverId ' => $ this ->getServerId (),
140
+ 'pubsub ' => "{$ appId }: {$ channel }" ,
139
141
]);
140
142
141
143
return true ;
@@ -150,23 +152,24 @@ public function subscribe(string $appId, string $channel): bool
150
152
*/
151
153
public function unsubscribe (string $ appId , string $ channel ): bool
152
154
{
153
- if (! isset ($ this ->subscribedChannels ["$ appId: $ channel " ])) {
155
+ if (! isset ($ this ->subscribedChannels ["{ $ appId} : { $ channel} " ])) {
154
156
return false ;
155
157
}
156
158
157
159
// Decrement the subscription count for this channel
158
- $ this ->subscribedChannels ["$ appId: $ channel " ]--;
160
+ $ this ->subscribedChannels ["{ $ appId} : { $ channel} " ]--;
159
161
160
162
// If we no longer have subscriptions to that channel, unsubscribe
161
- if ($ this ->subscribedChannels ["$ appId: $ channel " ] < 1 ) {
162
- $ this ->subscribeClient ->__call ('unsubscribe ' , ["$ appId: $ channel " ]);
163
+ if ($ this ->subscribedChannels ["{ $ appId} : { $ channel} " ] < 1 ) {
164
+ $ this ->subscribeClient ->__call ('unsubscribe ' , ["{ $ appId} : { $ channel} " ]);
163
165
164
- unset($ this ->subscribedChannels ["$ appId: $ channel " ]);
166
+ unset($ this ->subscribedChannels ["{ $ appId} : { $ channel} " ]);
165
167
}
166
168
167
169
DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATOR_UNSUBSCRIBED , [
168
170
'channel ' => $ channel ,
169
171
'serverId ' => $ this ->getServerId (),
172
+ 'pubsub ' => "{$ appId }: {$ channel }" ,
170
173
]);
171
174
172
175
return true ;
@@ -184,13 +187,14 @@ public function unsubscribe(string $appId, string $channel): bool
184
187
*/
185
188
public function joinChannel (string $ appId , string $ channel , string $ socketId , string $ data )
186
189
{
187
- $ this ->publishClient ->__call ('hset ' , ["$ appId: $ channel " , $ socketId , $ data ]);
190
+ $ this ->publishClient ->__call ('hset ' , ["{ $ appId} : { $ channel} " , $ socketId , $ data ]);
188
191
189
192
DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATOR_JOINED_CHANNEL , [
190
193
'channel ' => $ channel ,
191
194
'serverId ' => $ this ->getServerId (),
192
195
'socketId ' => $ socketId ,
193
196
'data ' => $ data ,
197
+ 'pubsub ' => "{$ appId }: {$ channel }" ,
194
198
]);
195
199
}
196
200
@@ -205,12 +209,13 @@ public function joinChannel(string $appId, string $channel, string $socketId, st
205
209
*/
206
210
public function leaveChannel (string $ appId , string $ channel , string $ socketId )
207
211
{
208
- $ this ->publishClient ->__call ('hdel ' , ["$ appId: $ channel " , $ socketId ]);
212
+ $ this ->publishClient ->__call ('hdel ' , ["{ $ appId} : { $ channel} " , $ socketId ]);
209
213
210
214
DashboardLogger::log ($ appId , DashboardLogger::TYPE_REPLICATOR_LEFT_CHANNEL , [
211
215
'channel ' => $ channel ,
212
216
'serverId ' => $ this ->getServerId (),
213
217
'socketId ' => $ socketId ,
218
+ 'pubsub ' => "{$ appId }: {$ channel }" ,
214
219
]);
215
220
}
216
221
@@ -223,7 +228,7 @@ public function leaveChannel(string $appId, string $channel, string $socketId)
223
228
*/
224
229
public function channelMembers (string $ appId , string $ channel ): PromiseInterface
225
230
{
226
- return $ this ->publishClient ->__call ('hgetall ' , ["$ appId: $ channel " ])
231
+ return $ this ->publishClient ->__call ('hgetall ' , ["{ $ appId} : { $ channel} " ])
227
232
->then (function ($ members ) {
228
233
// The data is expected as objects, so we need to JSON decode
229
234
return array_map (function ($ user ) {
@@ -244,7 +249,7 @@ public function channelMemberCounts(string $appId, array $channelNames): Promise
244
249
$ this ->publishClient ->__call ('multi ' , []);
245
250
246
251
foreach ($ channelNames as $ channel ) {
247
- $ this ->publishClient ->__call ('hlen ' , ["$ appId: $ channel " ]);
252
+ $ this ->publishClient ->__call ('hlen ' , ["{ $ appId} : { $ channel} " ]);
248
253
}
249
254
250
255
return $ this ->publishClient ->__call ('exec ' , [])
0 commit comments