| @@ -13,7 +13,7 @@ namespace cppamqp | |||||
| struct connection | struct connection | ||||
| { | { | ||||
| private: | |||||
| public: | |||||
| static inline const std::string& default_vhost (); | static inline const std::string& default_vhost (); | ||||
| static inline const std::string& default_username (); | static inline const std::string& default_username (); | ||||
| static inline const std::string& default_password (); | static inline const std::string& default_password (); | ||||
| @@ -47,12 +47,14 @@ namespace cppamqp | |||||
| const std::string& p_username = default_username(), | const std::string& p_username = default_username(), | ||||
| const std::string& p_password = default_password(), | const std::string& p_password = default_password(), | ||||
| const std::string& p_vhost = default_vhost(), | const std::string& p_vhost = default_vhost(), | ||||
| int p_heartbeat = AMQP_DEFAULT_HEARTBEAT, | |||||
| int p_max_channels = AMQP_DEFAULT_MAX_CHANNELS, | int p_max_channels = AMQP_DEFAULT_MAX_CHANNELS, | ||||
| int p_max_frame_size = AMQP_DEFAULT_FRAME_SIZE); | int p_max_frame_size = AMQP_DEFAULT_FRAME_SIZE); | ||||
| void login_external( | void login_external( | ||||
| const std::string& p_identify, | const std::string& p_identify, | ||||
| const std::string& p_vhost = default_vhost(), | const std::string& p_vhost = default_vhost(), | ||||
| int p_heartbeat = AMQP_DEFAULT_HEARTBEAT, | |||||
| int p_max_channels = AMQP_DEFAULT_MAX_CHANNELS, | int p_max_channels = AMQP_DEFAULT_MAX_CHANNELS, | ||||
| int p_max_frame_size = AMQP_DEFAULT_FRAME_SIZE); | int p_max_frame_size = AMQP_DEFAULT_FRAME_SIZE); | ||||
| @@ -15,7 +15,8 @@ namespace cppamqp | |||||
| { } | { } | ||||
| exception::exception(const std::string& p_message, amqp_status_enum p_status) : | exception::exception(const std::string& p_message, amqp_status_enum p_status) : | ||||
| utl::exception (p_message), | |||||
| utl::exception (p_message + " - " + amqp_error_string2(p_status) + | |||||
| "(" + std::to_string(static_cast<int>(p_status)) + ")"), | |||||
| status (p_status) | status (p_status) | ||||
| { } | { } | ||||
| @@ -69,26 +69,28 @@ void connection::tcp_connect(const std::string& hostname, uint port) | |||||
| } | } | ||||
| void connection::login_plain( | void connection::login_plain( | ||||
| const std::string& username, | |||||
| const std::string& password, | |||||
| const std::string& vhost, | |||||
| int maxChannels, | |||||
| int maxFrameSize) | |||||
| const std::string& p_username, | |||||
| const std::string& p_password, | |||||
| const std::string& p_vhost, | |||||
| int p_heartbeat, | |||||
| int p_max_channels, | |||||
| int p_max_frame_size) | |||||
| { | { | ||||
| __impl::check_and_raise( | __impl::check_and_raise( | ||||
| amqp_login(handle(), vhost.c_str(), maxChannels, maxFrameSize, 0, AMQP_SASL_METHOD_PLAIN, username.c_str(), password.c_str()), | |||||
| amqp_login(handle(), p_vhost.c_str(), p_max_channels, p_max_frame_size, p_heartbeat, AMQP_SASL_METHOD_PLAIN, p_username.c_str(), p_password.c_str()), | |||||
| "error while login plain", | "error while login plain", | ||||
| false); | false); | ||||
| } | } | ||||
| void connection::login_external( | void connection::login_external( | ||||
| const std::string& identify, | |||||
| const std::string& vhost, | |||||
| int maxChannels, | |||||
| int maxFrameSize) | |||||
| const std::string& p_identify, | |||||
| const std::string& p_vhost, | |||||
| int p_heartbeat, | |||||
| int p_max_channels, | |||||
| int p_max_frame_size) | |||||
| { | { | ||||
| __impl::check_and_raise( | __impl::check_and_raise( | ||||
| amqp_login(handle(), vhost.c_str(), maxChannels, maxFrameSize, 0, AMQP_SASL_METHOD_EXTERNAL, identify.c_str()), | |||||
| amqp_login(handle(), p_vhost.c_str(), p_max_channels, p_max_frame_size, p_heartbeat, AMQP_SASL_METHOD_EXTERNAL, p_identify.c_str()), | |||||
| "error while login external", | "error while login external", | ||||
| false); | false); | ||||
| } | } | ||||
| @@ -14,7 +14,7 @@ void ::cppamqp::__impl::check_and_raise(int returnCode, std::string msg, bool lo | |||||
| log_global_message(error, msg); | log_global_message(error, msg); | ||||
| } | } | ||||
| else | else | ||||
| throw cppamqp::exception(static_cast<amqp_status_enum>(returnCode)); | |||||
| throw cppamqp::exception(msg, static_cast<amqp_status_enum>(returnCode)); | |||||
| } | } | ||||
| void ::cppamqp::__impl::check_and_raise(const amqp_rpc_reply_t& reply, std::string msg, bool logOnly) | void ::cppamqp::__impl::check_and_raise(const amqp_rpc_reply_t& reply, std::string msg, bool logOnly) | ||||