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/src/server_session.cpp | |
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/src/server_session.cpp')
-rw-r--r-- | server/src/server_session.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
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; |