diff options
Diffstat (limited to 'server/src/event_subscription_repeated.cpp')
-rw-r--r-- | server/src/event_subscription_repeated.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/server/src/event_subscription_repeated.cpp b/server/src/event_subscription_repeated.cpp index 13e0165..bc41f7a 100644 --- a/server/src/event_subscription_repeated.cpp +++ b/server/src/event_subscription_repeated.cpp @@ -20,13 +20,44 @@ #include "event_subscription_repeated.h" +#include <boost/bind.hpp> -event_subscription_repeated::event_subscription_repeated(client_event_subscription_request *req) +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; + 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() { + delete timer; } + +void event_subscription_repeated::timer_handler(const boost::system::error_code &e) +{ + if(!e) + { + //TODO: fire event + if(!subscription_request.one_time()) + { + timer->expires_from_now(boost::posix_time::milliseconds(subscription_request.interval())); + timer->async_wait(boost::bind(&event_subscription_repeated::timer_handler, this, _1)); + } + else + { + //TODO: remove entry from events subscription list in client object + delete this; + } + } + else + { + //TODO: handle error + //TODO: remove entry from events subscription list in client object + delete this; + } +} |