diff options
Diffstat (limited to 'src/components/connection_handler/include/connection_handler/connection.h')
-rw-r--r-- | src/components/connection_handler/include/connection_handler/connection.h | 134 |
1 files changed, 71 insertions, 63 deletions
diff --git a/src/components/connection_handler/include/connection_handler/connection.h b/src/components/connection_handler/include/connection_handler/connection.h index 6bcbc3fdcd..d20ddc1c00 100644 --- a/src/components/connection_handler/include/connection_handler/connection.h +++ b/src/components/connection_handler/include/connection_handler/connection.h @@ -37,6 +37,7 @@ #include <vector> #include "utils/lock.h" +#include "utils/threads/thread.h" #include "connection_handler/device.h" #include "connection_handler/heartbeat_monitor.h" #include "protocol/service_type.h" @@ -48,26 +49,25 @@ class SSLContext; #endif // ENABLE_SECURITY /** - * \namespace connection_handler - * \brief SmartDeviceLink connection_handler namespace. + *@brief SmartDeviceLink connection_handler namespace. */ namespace connection_handler { class ConnectionHandler; /** - * \brief Type for ConnectionHandle + * @brief Type for ConnectionHandle */ typedef int32_t ConnectionHandle; /** - * \brief Type for Connections map + * @brief Type for Connections map * Key is ConnectionHandle which is unique */ typedef std::map<int32_t, Connection*> ConnectionList; /** - * \brief ServiceType + * @brief ServiceType */ struct Service { protocol_handler::ServiceType service_type; @@ -86,7 +86,7 @@ struct Service { }; /** - * \brief Type for Session Services + * @brief Type for Session Services */ typedef std::vector<Service> ServiceList; @@ -114,18 +114,17 @@ struct Session { }; /** - * \brief Type for Session map + * @brief Type for Session map */ typedef std::map<uint8_t, Session> SessionMap; /** - * \class Connection - * \brief Stores connection information + * @brief Stores connection information */ class Connection { public: /** - * \brief Class constructor + * @brief Class constructor */ Connection(ConnectionHandle connection_handle, DeviceHandle connection_device_handle, @@ -133,162 +132,171 @@ class Connection { int32_t heartbeat_timeout); /** - * \brief Destructor + * @brief Destructor */ ~Connection(); /** - * \brief Returns device handle - * \return DeviceHandle + * @brief Returns device handle + * @return DeviceHandle */ ConnectionHandle connection_handle() const; /** - * \brief Returns connection device handle - * \return ConnectionDeviceHandle + * @brief Returns connection device handle + * @return ConnectionDeviceHandle */ DeviceHandle connection_device_handle(); /** - * \brief Adds session to connection - * \return new session id or 0 in case of issues + * @brief Adds session to connection + * @return new session id or 0 in case of issues */ uint32_t AddNewSession(); /** - * \brief Removes session from connection - * \param session session ID - * \return session_id or 0 in case of issues + * @brief Removes session from connection + * @param session session ID + * @return session_id or 0 in case of issues */ uint32_t RemoveSession(uint8_t session_id); /** - * \brief Adds uprotected service to session or + * @brief Adds uprotected service to session or * check protection to service has been started before - * \param session_id session ID - * \param service_type Type of service - * \param is_protected protection state - * \return TRUE on success, otherwise FALSE + * @param session_id session ID + * @param service_type Type of service + * @param is_protected protection state + * @return TRUE on success, otherwise FALSE */ bool AddNewService(uint8_t session_id, protocol_handler::ServiceType service_type, const bool is_protected); /** - * \brief Removes service from session - * \param session_id session ID - * \param service_type Type of service - * \return TRUE on success, otherwise FALSE + * @brief Removes service from session + * @param session_id session ID + * @param service_type Type of service + * @return TRUE on success, otherwise FALSE */ bool RemoveService(uint8_t session_id, protocol_handler::ServiceType service_type); #ifdef ENABLE_SECURITY /** - * \brief Sets crypto context of service - * \param session_id Identifier of the session - * \param context SSL for connection - * \return \c true in case of service is protected or \c false otherwise + * @brief Sets crypto context of service + * @param session_id Identifier of the session + * @param context SSL for connection + * @return \c true in case of service is protected or \c false otherwise */ int SetSSLContext(uint8_t session_id, security_manager::SSLContext *context); /** - * \brief Gets crypto context of session, use service_type to get NULL + * @brief Gets crypto context of session, use service_type to get NULL * SSLContext for not protected services or ControlService (0x0) * to get current SSLContext of connection - * \param session_id Identifier of the session - * \param service_type Type of service - * \return \ref SSLContext of connection + * @param session_id Identifier of the session + * @param service_type Type of service + * @return \ref SSLContext of connection */ security_manager::SSLContext *GetSSLContext( const uint8_t session_id, const protocol_handler::ServiceType &service_type) const; /** - * \brief Set protection flag to service in session by key + * @brief Set protection flag to service in session by key * to get current SSLContext of connection - * \param session_id Identifier of the session - * \param service_type Type of service + * @param session_id Identifier of the session + * @param service_type Type of service */ void SetProtectionFlag( const uint8_t session_id, const protocol_handler::ServiceType &service_type); #endif // ENABLE_SECURITY /** - * \brief Returns map of sessions which have been opened in + * @brief Returns map of sessions which have been opened in * current connection. */ const SessionMap session_map() const; /** - * \brief Close session - * \param session_id session id + * @brief Close session + * @param session_id session id */ void CloseSession(uint8_t session_id); /** - * \brief Prevent session from being closed by heartbeat timeout - * \param session_id session id + * @brief Prevent session from being closed by heartbeat timeout + * @param session_id session id */ void KeepAlive(uint8_t session_id); /** - * \brief Start heartbeat for specified session - * \param session_id session id + * @brief Start heartbeat for specified session + * @param session_id session id */ void StartHeartBeat(uint8_t session_id); /** - * \brief Send heartbeat to mobile app - * \param session_id session id + * @brief Send heartbeat to mobile app + * @param session_id session id */ void SendHeartBeat(uint8_t session_id); /** - * Sets heart beat timeout + * @brief Sets heart beat timeout * @param timeout in seconds */ - void SetHeartBeatTimeout(int32_t timeout); + void SetHeartBeatTimeout(int32_t timeout, uint8_t session_id); /** - * \brief changes protocol version in session - * \param session_id session id - * \param protocol_version protocol version registered application + * @brief changes protocol version in session + * @param session_id session id + * @param protocol_version protocol version registered application */ void UpdateProtocolVersionSession(uint8_t session_id, uint8_t protocol_version); /** - * \brief checks if session supports heartbeat - * \param session_id session id - * \return TRUE on success, otherwise FALSE + * @brief checks if session supports heartbeat + * @param session_id session id + * @return TRUE on success, otherwise FALSE */ bool SupportHeartBeat(uint8_t session_id); + /** + * @brief find protocol version for session + * @param session_id id of session which is launched on mobile side + * @param protocol_version method writes value protocol version + * @return TRUE if session exists otherwise + * return FALSE + */ + bool ProtocolVersion(uint8_t session_id, uint8_t& protocol_version); + private: /** - * \brief Current connection handler. + * @brief Current connection handler. */ ConnectionHandler *connection_handler_; /** - * \brief Current connection handle. + * @brief Current connection handle. */ ConnectionHandle connection_handle_; /** - * \brief DeviceHandle of this connection. + * @brief DeviceHandle of this connection. */ DeviceHandle connection_device_handle_; /** - * \brief session/services map + * @brief session/services map */ SessionMap session_map_; mutable sync_primitives::Lock session_map_lock_; /** - * \brief monitor that closes connection if there is no traffic over it + * @brief monitor that closes connection if there is no traffic over it */ - HeartBeatMonitor *heartbeat_monitor_; + HeartBeatMonitor* heartbeat_monitor_; threads::Thread *heart_beat_monitor_thread_; DISALLOW_COPY_AND_ASSIGN(Connection); |