1616
1717#include " ByteVector.hpp" // ByteVector
1818#include " Decoder.hpp" // Decoder
19+ #include " DecoderFactory.hpp"
1920#include " UniqueFd.hpp" // UniqueFd
2021
2122namespace tcp_in {
@@ -26,10 +27,10 @@ class Connection {
2627 /* *
2728 * @brief Creates new connection with this TCP connection file descriptor.
2829 * @param fd File descriptor of the new tcp connection.
29- * @param decoder Decoder to use in this connection.
30+ * @param factory The decoder factory to decide the decoder of this connection
3031 * @throws when fails to create new session
3132 */
32- Connection (UniqueFd fd, std::unique_ptr<Decoder> decoder );
33+ Connection (UniqueFd fd, DecoderFactory& factory, ipx_ctx_t *ctx );
3334
3435 Connection (const Connection &) = delete ;
3536
@@ -69,13 +70,18 @@ class Connection {
6970private:
7071 void send_msg (ipx_ctx_t *ctx, ByteVector &&msg);
7172
72- ipx_session *m_session;
7373 /* * TCP file descriptor */
7474 UniqueFd m_fd;
75+ /* * Decoder factory */
76+ DecoderFactory &m_factory;
77+ /* * Plugin context for logging */
78+ ipx_ctx_t *m_ctx;
79+ /* * The session identifier */
80+ ipx_session *m_session = nullptr ;
7581 /* * true if this connection didn't receive any full messages, otherwise false. */
76- bool m_new_connnection;
82+ bool m_new_connnection = true ;
7783 /* * selected decoder or nullptr. */
78- std::unique_ptr<Decoder> m_decoder;
84+ std::unique_ptr<Decoder> m_decoder = nullptr ;
7985};
8086
8187} // namespace tcp_in
0 commit comments