From 028ddc8e576e78d500f1cba443d7e21401130bb6 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Thu, 11 Aug 2016 08:54:06 +0300 Subject: server: event_system: draft implementation of repeated events (we still have none defined by protcol) more appropriate names for some enums and structs messaging: a bit of refactoring in server_session (cut message handler to separate functions for each message type) more appropriate names for some functions curl_downloader: updating downloaded size variable during download process (thread safety required) --- server/src/event_subscription_repeated.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'server/src/event_subscription_repeated.cpp') diff --git a/server/src/event_subscription_repeated.cpp b/server/src/event_subscription_repeated.cpp index 4291dfa..04c0944 100644 --- a/server/src/event_subscription_repeated.cpp +++ b/server/src/event_subscription_repeated.cpp @@ -22,14 +22,16 @@ #include "event_subscription_repeated.h" #include +#include "client.h" + extern boost::asio::io_service io_service_server; event_subscription_repeated::event_subscription_repeated(client_event_subscription_request *req) : event_subscription_base(req) { - subtype = EVENT_SUBTYPE_REPEATED; + subtype = EVENT_MODE_REPEATED; timer = new deadline_timer(io_service_server, boost::posix_time::milliseconds(req->interval())); - timer->async_wait(boost::bind(&event_subscription_repeated::timer_handler, this, _1)); + } event_subscription_repeated::~event_subscription_repeated() @@ -40,8 +42,9 @@ event_subscription_repeated::~event_subscription_repeated() void event_subscription_repeated::timer_handler(const boost::system::error_code &e) { - if(!e) + if(!e && this->owner) { + this->owner->fire_event(&subscription_request); //TODO: fire event if(!subscription_request.one_time()) { @@ -61,3 +64,19 @@ void event_subscription_repeated::timer_handler(const boost::system::error_code delete this; } } + +void event_subscription_repeated::start() +{ + timer->async_wait(boost::bind(&event_subscription_repeated::timer_handler, this, _1)); +} + +const client* event_subscription_repeated::get_owner() +{ + return owner; +} + +void event_subscription_repeated::set_owner(client* c) +{ + owner = c; +} + -- cgit v1.2.3