diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-11-23 20:17:56 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-11-23 20:17:56 +0300 |
commit | d233b343940602429c4db1fb1bc2c0192240fd75 (patch) | |
tree | 7875ed9aab2c50d343b2ec3f9fb7257e60ec7279 /server | |
parent | 7ef827ea95590c3096f7f6255c5d40eb447d4178 (diff) |
client-qt:
added subscription to download deleted event (handler not implemented yet)
server:
simplified "fire _event" implementation
basic implementation of "add_event_subscription" in client class
Diffstat (limited to 'server')
-rw-r--r-- | server/include/event_subscription_base.h | 4 | ||||
-rw-r--r-- | server/src/client.cpp | 1 | ||||
-rw-r--r-- | server/src/server_session.cpp | 15 |
3 files changed, 7 insertions, 13 deletions
diff --git a/server/include/event_subscription_base.h b/server/include/event_subscription_base.h index aac316b..4cae7e1 100644 --- a/server/include/event_subscription_base.h +++ b/server/include/event_subscription_base.h @@ -37,10 +37,6 @@ public: { subscription_request = *req; } - bool operator==(const SUBSCRIPTION_TYPE t) - { - return subscription_request.type() == t; - } const EVENT_SUBTYPE get_subtype() { return subtype; diff --git a/server/src/client.cpp b/server/src/client.cpp index fdfd513..20d519a 100644 --- a/server/src/client.cpp +++ b/server/src/client.cpp @@ -28,6 +28,7 @@ client::client(std::string &client_auth_token, server_session *sess) : auth_toke void client::add_event_subscription(event_subscription_base* e) { + subscriptions.push_back(e); } const std::list<event_subscription_base*>& client::get_subscriptions() { diff --git a/server/src/server_session.cpp b/server/src/server_session.cpp index 0d92341..b572980 100644 --- a/server/src/server_session.cpp +++ b/server/src/server_session.cpp @@ -644,19 +644,16 @@ void server_session::handle_write(const boost::system::error_code& error) // boost::asio::async_read(socket_, boost::asio::buffer(recv_data_, 4), boost::bind(&server_session::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } -bool operator==(event_subscription_base* const e, const SUBSCRIPTION_TYPE t) -{ - return *e == t; -} - void server_session::fire_event(SUBSCRIPTION_TYPE type, server_msg &msg) { for(auto i : clients) { - for(auto s = std::find(i.second->get_subscriptions().begin(), i.second->get_subscriptions().end(), type); s != i.second->get_subscriptions().end(); s = std::find(s, i.second->get_subscriptions().end(), type)) + for(auto s : i.second->get_subscriptions()) { - if((*s)->get_subtype() != EVENT_SUBTYPE::EVENT_SUBTYPE_EVENT) + if(s->get_subscription_request().type() != type) + continue; + if(s->get_subtype() != EVENT_SUBTYPE::EVENT_SUBTYPE_EVENT) continue; switch(type) { @@ -672,8 +669,8 @@ void server_session::fire_event(SUBSCRIPTION_TYPE type, server_msg &msg) filtered_message.set_type(msg.type()); for(auto sc : msg.download_state_changes()) { - auto dsc = std::find((*s)->get_subscription_request().download_state_change().states().begin(), (*s)->get_subscription_request().download_state_change().states().end(), sc.state()); - if(dsc != (*s)->get_subscription_request().download_state_change().states().end()) + auto dsc = std::find(s->get_subscription_request().download_state_change().states().begin(), s->get_subscription_request().download_state_change().states().end(), sc.state()); + if(dsc != s->get_subscription_request().download_state_change().states().end()) { auto sc2 = filtered_message.add_download_state_changes(); *sc2 = sc; |