diff libirccd/irccd/daemon/transport_client.hpp @ 773:8c44bbcbbab9

Misc: style, cleanup and update
author David Demelier <markand@malikania.fr>
date Fri, 26 Oct 2018 13:01:00 +0200
parents 3f5e8ae58a84
children 560b62f6b0a7
line wrap: on
line diff
--- a/libirccd/irccd/daemon/transport_client.hpp	Wed Oct 24 13:24:03 2018 +0200
+++ b/libirccd/irccd/daemon/transport_client.hpp	Fri Oct 26 13:01:00 2018 +0200
@@ -36,106 +36,107 @@
  */
 class transport_client : public std::enable_shared_from_this<transport_client> {
 public:
-    /**
-     * Client state.
-     */
-    enum class state {
-        authenticating,                     //!< client is authenticating
-        ready,                              //!< client is ready
-        closing                             //!< client is closing
-    };
+	/**
+	 * Client state.
+	 */
+	enum class state {
+		authenticating,         //!< client is authenticating
+		ready,                  //!< client is ready
+		closing                 //!< client is closing
+	};
 
 private:
-    state state_{state::authenticating};
-    std::weak_ptr<transport_server> parent_;
-    std::shared_ptr<io::stream> stream_;
-    std::deque<std::pair<nlohmann::json, io::write_handler>> queue_;
+	state state_{state::authenticating};
+	std::weak_ptr<transport_server> parent_;
+	std::shared_ptr<stream> stream_;
+	std::deque<std::pair<nlohmann::json, stream::write_handler>> queue_;
 
-    void flush();
-    void erase();
+	void flush();
+	void erase();
 
 public:
-    /**
-     * Constructor.
-     *
-     * \pre stream != nullptr
-     * \param server the parent
-     * \param stream the I/O stream
-     */
-    transport_client(std::weak_ptr<transport_server> server, std::shared_ptr<io::stream> stream) noexcept;
+	/**
+	 * Constructor.
+	 *
+	 * \pre stream != nullptr
+	 * \param server the parent
+	 * \param stream the I/O stream
+	 */
+	transport_client(std::weak_ptr<transport_server> server,
+	                 std::shared_ptr<stream> stream) noexcept;
 
-    /**
-     * Get the current client state.
-     *
-     * \return the state
-     */
-    auto get_state() const noexcept -> state;
+	/**
+	 * Get the current client state.
+	 *
+	 * \return the state
+	 */
+	auto get_state() const noexcept -> state;
 
-    /**
-     * Set the client state.
-     *
-     * \param state the new state
-     */
-    void set_state(state state) noexcept;
+	/**
+	 * Set the client state.
+	 *
+	 * \param state the new state
+	 */
+	void set_state(state state) noexcept;
 
-    /**
-     * Start receiving if not closed.
-     *
-     * Possible error codes:
-     *
-     *   - std::errc::network_down in case of errors,
-     *   - std::errc::invalid_argument if the JSON message is invalid,
-     *   - std::errc::not_enough_memory in case of memory failure.
-     *
-     * \pre handler != nullptr
-     * \param handler the handler
-     * \warning Another read operation MUST NOT be running.
-     */
-    void read(io::read_handler handler);
+	/**
+	 * Start receiving if not closed.
+	 *
+	 * Possible error codes:
+	 *
+	 *   - std::errc::network_down in case of errors,
+	 *   - std::errc::invalid_argument if the JSON message is invalid,
+	 *   - std::errc::not_enough_memory in case of memory failure.
+	 *
+	 * \pre handler != nullptr
+	 * \param handler the handler
+	 * \warning Another read operation MUST NOT be running.
+	 */
+	void read(stream::read_handler handler);
 
-    /**
-     * Start sending if not closed.
-     *
-     * Possible error codes:
-     *
-     *   - boost::system::errc::network_down in case of errors,
-     *
-     * \pre json.is_object()
-     * \param json the json message
-     * \param handler the optional handler
-     * \note If a write operation is running, it is postponed once ready.
-     */
-    void write(nlohmann::json json, io::write_handler handler = nullptr);
+	/**
+	 * Start sending if not closed.
+	 *
+	 * Possible error codes:
+	 *
+	 *   - boost::system::errc::network_down in case of errors,
+	 *
+	 * \pre json.is_object()
+	 * \param json the json message
+	 * \param handler the optional handler
+	 * \note If a write operation is running, it is postponed once ready.
+	 */
+	void write(nlohmann::json json, stream::write_handler handler = nullptr);
 
-    /**
-     * Convenient success message.
-     *
-     * \param command the command name
-     * \param handler the optional handler
-     * \note If a write operation is running, it is postponed once ready.
-     */
-    void success(const std::string& command, io::write_handler handler = nullptr);
+	/**
+	 * Convenient success message.
+	 *
+	 * \param command the command name
+	 * \param handler the optional handler
+	 * \note If a write operation is running, it is postponed once ready.
+	 */
+	void success(const std::string& command, stream::write_handler handler = nullptr);
 
-    /**
-     * Send an error code to the client.
-     *
-     * \pre code is not 0
-     * \param code the error code
-     * \param handler the optional handler
-     * \note If a write operation is running, it is postponed once ready.
-     */
-    void error(std::error_code code, io::write_handler handler = nullptr);
+	/**
+	 * Send an error code to the client.
+	 *
+	 * \pre code is not 0
+	 * \param code the error code
+	 * \param handler the optional handler
+	 * \note If a write operation is running, it is postponed once ready.
+	 */
+	void error(std::error_code code, stream::write_handler handler = nullptr);
 
-    /**
-     * Send an error code to the client.
-     *
-     * \pre code is not 0
-     * \param code the error code
-     * \param command the command name
-     * \param handler the optional handler
-     * \note If a write operation is running, it is postponed once ready.
-     */
-    void error(std::error_code code, std::string_view command, io::write_handler handler = nullptr);
+	/**
+	 * Send an error code to the client.
+	 *
+	 * \pre code is not 0
+	 * \param code the error code
+	 * \param command the command name
+	 * \param handler the optional handler
+	 * \note If a write operation is running, it is postponed once ready.
+	 */
+	void error(std::error_code code, std::string_view command, stream::write_handler handler = nullptr);
 };
 
 } // !irccd