summaryrefslogtreecommitdiff
path: root/server/src/event_subscription_repeated.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2016-08-11 08:54:06 +0300
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2016-08-11 08:54:06 +0300
commit028ddc8e576e78d500f1cba443d7e21401130bb6 (patch)
tree8c3a3b1ae9899eaafb490e776d6407bb16f6213d /server/src/event_subscription_repeated.cpp
parentd9ffc27c8b563d76a493ec9eafad56ec5dda13b9 (diff)
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)
Diffstat (limited to 'server/src/event_subscription_repeated.cpp')
-rw-r--r--server/src/event_subscription_repeated.cpp25
1 files changed, 22 insertions, 3 deletions
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 <boost/bind.hpp>
+#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;
+}
+