Skip to content

Commit 5e11b04

Browse files
committed
Clean code. Remove deprecated method in channel.
1 parent 13860a8 commit 5e11b04

File tree

5 files changed

+10
-18
lines changed

5 files changed

+10
-18
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ boost::bind(bind_func_with_params, _1, 123, param2);
194194
To authenticate a user a separate C++ HTTP client library is required.
195195
196196
197+
## TODO
198+
199+
* Add timestamp to events so that it is possible to clean the events queue with old events without response.
200+
* Implement a clean-up method for the queue.
201+
* See how to persist the connection object (```this->conn```) in the dispatcher so that the function ```trigger()``` can put the event trigger in event_queue if disconnected.
202+
203+
197204
## Author
198205
199206
Egon Zemmer, Phlegx Systems - @phlegx

websocket-rails-client/channel.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,6 @@ Event Channel::trigger(std::string event_name, jsonxx::Object event_data) {
8787
}
8888
}
8989

90-
Event Channel::trigger(std::string event_name, jsonxx::Object event_data, cb_func success_callback, cb_func failure_callback) {
91-
jsonxx::Array data = this->initEventData(event_name);
92-
data.get<jsonxx::Object>(1).import("channel", this->name);
93-
data.get<jsonxx::Object>(1).import("data", event_data);
94-
data.get<jsonxx::Object>(1).import("token", this->token);
95-
Event event(data, success_callback, failure_callback);
96-
if(this->token.empty()) {
97-
this->event_queue.push(event);
98-
return event;
99-
} else {
100-
return this->dispatcher->triggerEvent(event);
101-
}
102-
}
103-
10490

10591
std::string Channel::getName() {
10692
return this->name;

websocket-rails-client/channel.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class Channel {
4646
void destroy();
4747
void bind(std::string event_name, cb_func callback);
4848
Event trigger(std::string event_name, jsonxx::Object event_data);
49-
Event trigger(std::string event_name, jsonxx::Object event_data, cb_func success_callback, cb_func failure_callback);
5049
std::string getName();
5150
map_vec_cb_func getCallbacks();
5251
void setCallbacks(map_vec_cb_func callbacks);

websocket-rails-client/websocket_connection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void WebsocketConnection::messageHandler(websocketpp::connection_hdl hdl, messag
181181

182182

183183
void WebsocketConnection::sendEvent(Event event) {
184-
if(this->connection_id != "0") {
184+
if(this->connection_id != "") {
185185
event.setConnectionId(this->connection_id);
186186
}
187187
websocketpp::lib::error_code ec;

websocket-rails-client/websocket_rails.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Event WebsocketRails::triggerEvent(Event event) {
206206
************************************/
207207

208208
Channel WebsocketRails::subscribe(std::string channel_name) {
209-
if (this->channels.find(channel_name) == this->channels.end()) {
209+
if(this->channels.find(channel_name) == this->channels.end()) {
210210
Channel channel(channel_name, *this, false);
211211
this->channels[channel_name] = channel;
212212
return channel;
@@ -217,7 +217,7 @@ Channel WebsocketRails::subscribe(std::string channel_name) {
217217

218218

219219
Channel WebsocketRails::subscribe(std::string channel_name, cb_func success_callback, cb_func failure_callback) {
220-
if (this->channels.find(channel_name) == this->channels.end()) {
220+
if(this->channels.find(channel_name) == this->channels.end()) {
221221
Channel channel(channel_name, *this, false, success_callback, failure_callback);
222222
this->channels[channel_name] = channel;
223223
return channel;

0 commit comments

Comments
 (0)