@@ -72,7 +72,7 @@ WebsocketRails::connection WebsocketRails::reconnect() {
72
72
std::string oldconnection_id = this ->conn != 0 ? this ->conn ->getConnectionId () : " " ;
73
73
this ->disconnect ();
74
74
if (this ->connect () == " connected" ) {
75
- for (auto & x: this ->queue ) {
75
+ for (auto & x: this ->event_queue ) {
76
76
Event event = x.second ;
77
77
if (event.getConnectionId () == oldconnection_id && !event.isResult ()) {
78
78
this ->triggerEvent (event);
@@ -118,10 +118,10 @@ void WebsocketRails::newMessage(jsonxx::Array data) {
118
118
jsonxx::Array socket_message = data.get <jsonxx::Array>(_i);
119
119
Event event (socket_message);
120
120
if (event.isResult ()) {
121
- if (this ->queue .find (event.getId ()) != this ->queue .end ()) {
122
- this ->queue [event.getId ()].runCallbacks (event.getSuccess (), event.getData ());
121
+ if (this ->event_queue .find (event.getId ()) != this ->event_queue .end ()) {
122
+ this ->event_queue [event.getId ()].runCallbacks (event.getSuccess (), event.getData ());
123
123
}
124
- this ->queue .erase (event.getId ());
124
+ this ->event_queue .erase (event.getId ());
125
125
} else if (event.isChannel ()) {
126
126
this ->dispatchChannel (event);
127
127
} else if (event.isPing ()) {
@@ -199,8 +199,8 @@ void WebsocketRails::trigger(std::string event_name, jsonxx::Object event_data,
199
199
200
200
201
201
void WebsocketRails::triggerEvent (Event event) {
202
- if (this ->queue .find (event.getId ()) == this ->queue .end ()) {
203
- this ->queue [event.getId ()] = event;
202
+ if (this ->event_queue .find (event.getId ()) == this ->event_queue .end ()) {
203
+ this ->event_queue [event.getId ()] = event;
204
204
}
205
205
if (this ->conn != 0 ) {
206
206
this ->conn ->trigger (event);
@@ -214,55 +214,55 @@ void WebsocketRails::triggerEvent(Event event) {
214
214
************************************/
215
215
216
216
Channel WebsocketRails::subscribe (std::string channel_name) {
217
- if (this ->channels .find (channel_name) == this ->channels .end ()) {
217
+ if (this ->channel_queue .find (channel_name) == this ->channel_queue .end ()) {
218
218
Channel channel (channel_name, *this , false );
219
- this ->channels [channel_name] = channel;
219
+ this ->channel_queue [channel_name] = channel;
220
220
return channel;
221
221
} else {
222
- return this ->channels [channel_name];
222
+ return this ->channel_queue [channel_name];
223
223
}
224
224
}
225
225
226
226
227
227
Channel WebsocketRails::subscribe (std::string channel_name, cb_func success_callback, cb_func failure_callback) {
228
- if (this ->channels .find (channel_name) == this ->channels .end ()) {
228
+ if (this ->channel_queue .find (channel_name) == this ->channel_queue .end ()) {
229
229
Channel channel (channel_name, *this , false , success_callback, failure_callback);
230
- this ->channels [channel_name] = channel;
230
+ this ->channel_queue [channel_name] = channel;
231
231
return channel;
232
232
} else {
233
- return this ->channels [channel_name];
233
+ return this ->channel_queue [channel_name];
234
234
}
235
235
}
236
236
237
237
238
238
Channel WebsocketRails::subscribePrivate (std::string channel_name) {
239
- if (this ->channels .find (channel_name) == this ->channels .end ()) {
239
+ if (this ->channel_queue .find (channel_name) == this ->channel_queue .end ()) {
240
240
Channel channel (channel_name, *this , true );
241
- this ->channels [channel_name] = channel;
241
+ this ->channel_queue [channel_name] = channel;
242
242
return channel;
243
243
} else {
244
- return this ->channels [channel_name];
244
+ return this ->channel_queue [channel_name];
245
245
}
246
246
}
247
247
248
248
249
249
Channel WebsocketRails::subscribePrivate (std::string channel_name, cb_func success_callback, cb_func failure_callback) {
250
- if (this ->channels .find (channel_name) == this ->channels .end ()) {
250
+ if (this ->channel_queue .find (channel_name) == this ->channel_queue .end ()) {
251
251
Channel channel (channel_name, *this , true , success_callback, failure_callback);
252
- this ->channels [channel_name] = channel;
252
+ this ->channel_queue [channel_name] = channel;
253
253
return channel;
254
254
} else {
255
- return this ->channels [channel_name];
255
+ return this ->channel_queue [channel_name];
256
256
}
257
257
}
258
258
259
259
260
260
void WebsocketRails::unsubscribe (std::string channel_name) {
261
- if (this ->channels .find (channel_name) == this ->channels .end ()) {
261
+ if (this ->channel_queue .find (channel_name) == this ->channel_queue .end ()) {
262
262
return ;
263
263
}
264
- this ->channels [channel_name].destroy ();
265
- this ->channels .erase (channel_name);
264
+ this ->channel_queue [channel_name].destroy ();
265
+ this ->channel_queue .erase (channel_name);
266
266
}
267
267
268
268
@@ -296,10 +296,10 @@ void WebsocketRails::dispatch(Event event) {
296
296
297
297
298
298
void WebsocketRails::dispatchChannel (Event event) {
299
- if (this ->channels .find (event.getChannel ()) == this ->channels .end ()) {
299
+ if (this ->channel_queue .find (event.getChannel ()) == this ->channel_queue .end ()) {
300
300
return ;
301
301
}
302
- this ->channels [event.getChannel ()].dispatch (event.getName (), event.getData ());
302
+ this ->channel_queue [event.getChannel ()].dispatch (event.getName (), event.getData ());
303
303
}
304
304
305
305
@@ -318,14 +318,14 @@ bool WebsocketRails::connectionStale() {
318
318
319
319
std::vector<Channel> WebsocketRails::reconnectChannels () {
320
320
std::vector<Channel> results;
321
- for (auto & x: this ->channels ) {
321
+ for (auto & x: this ->channel_queue ) {
322
322
Channel channel = x.second ;
323
- this -> callbacks = channel.getCallbacks ();
323
+ map_vec_cb_func callbacks = channel.getCallbacks ();
324
324
channel.destroy ();
325
325
std::string channel_name = channel.getName ();
326
- this ->channels .erase (channel_name);
326
+ this ->channel_queue .erase (channel_name);
327
327
channel = channel.isPrivate () ? this ->subscribePrivate (channel_name) : this ->subscribe (channel_name);
328
- channel.setCallbacks (this -> callbacks );
328
+ channel.setCallbacks (callbacks);
329
329
results.push_back (channel);
330
330
}
331
331
return results;
0 commit comments