diff options
Diffstat (limited to 'server/include')
-rw-r--r-- | server/include/client.h | 4 | ||||
-rw-r--r-- | server/include/event_subscription_base.h | 10 | ||||
-rw-r--r-- | server/include/event_subscription_repeated.h | 8 | ||||
-rw-r--r-- | server/include/server_session.h | 19 |
4 files changed, 31 insertions, 10 deletions
diff --git a/server/include/client.h b/server/include/client.h index e755fac..5aa4fb4 100644 --- a/server/include/client.h +++ b/server/include/client.h @@ -23,9 +23,10 @@ #include <string> #include <list> -#include "event_subscription_base.h" class server_session; +class event_subscription_base; +class client_event_subscription_request; class client { @@ -33,6 +34,7 @@ class client client(std::string &client_auth_token, server_session *sess = nullptr); void add_event_subscription(event_subscription_base* e); const std::list<event_subscription_base*>& get_subscriptions(); + void fire_event(client_event_subscription_request* e); virtual ~client(); protected: private: diff --git a/server/include/event_subscription_base.h b/server/include/event_subscription_base.h index b181dfd..635abba 100644 --- a/server/include/event_subscription_base.h +++ b/server/include/event_subscription_base.h @@ -25,9 +25,9 @@ //TODO: rework (events and polls separated ?) -enum EVENT_SUBTYPE { - EVENT_SUBTYPE_REPEATED = 0, //periodic firing based on timer - EVENT_SUBTYPE_EVENT = 1, //fired on event occurs (only can be used for data which support this event type) +enum EVENT_MODE { + EVENT_MODE_REPEATED = 0, //periodic firing based on timer + EVENT_MODE_EVENT = 1, //fired on event occurs (only can be used for data which support this event type) }; class event_subscription_base @@ -37,7 +37,7 @@ public: { subscription_request = *req; } - const EVENT_SUBTYPE get_subtype() + const EVENT_MODE get_subtype() { return subtype; } @@ -48,7 +48,7 @@ public: virtual ~event_subscription_base(){} protected: - EVENT_SUBTYPE subtype = EVENT_SUBTYPE::EVENT_SUBTYPE_EVENT; + EVENT_MODE subtype = EVENT_MODE::EVENT_MODE_EVENT; client_event_subscription_request subscription_request; }; diff --git a/server/include/event_subscription_repeated.h b/server/include/event_subscription_repeated.h index fc0d857..309c9ab 100644 --- a/server/include/event_subscription_repeated.h +++ b/server/include/event_subscription_repeated.h @@ -25,6 +25,8 @@ #include "event_subscription_base.h" #include <boost/asio.hpp> +class client; + typedef boost::asio::basic_deadline_timer<boost::posix_time::ptime> deadline_timer; class event_subscription_repeated : public event_subscription_base @@ -34,8 +36,14 @@ public: ~event_subscription_repeated(); void timer_handler(const boost::system::error_code &e); + + void start(); + const client* get_owner(); + void set_owner(client* c); + private: deadline_timer *timer; + client *owner = nullptr; }; #endif // EVENT_SUBSCRIPTION_PERIODIC_H diff --git a/server/include/server_session.h b/server/include/server_session.h index c0220f0..13f60fd 100644 --- a/server/include/server_session.h +++ b/server/include/server_session.h @@ -49,15 +49,26 @@ public: protected: private: server_session(const server_session&) = delete; - // net + // lowlevel net void handle_read(const boost::system::error_code& error, size_t bytes_transferred); void handle_write(const boost::system::error_code& error); void handle_write_no_read(const boost::system::error_code& error); void handle_handshake(const boost::system::error_code& error); - bool handle_command(client_msg* msg); //TODO: thread safety ? - void send_download_list(); - + //message handlers + //TODO: thread safety ? + bool handle_message(client_msg* msg); + bool handle_auth_request(client_msg *msg); + bool handle_modules_request(client_msg *msg); + bool handle_core_info_request(client_msg *msg); + bool handle_downloads_list_request(); + bool handle_download_info_request(client_msg *msg); + bool handle_download_add_request(client_msg *msg); + bool handle_download_start_request(client_msg *msg); + bool handle_download_stop_request(client_msg *msg); + bool handle_download_delete_request(client_msg *msg); + bool handle_subscription_request(client_msg *msg); + char* recv_data_ = nullptr; socket_wraper* socket_ = nullptr; boost::asio::io_service& io_service_; |