X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/6559a5e4376e705b8052162a67f79d6dff31a469..f3300c448f21eb61c08284f1e210bd7766da784e:/projects/rlm_stg/stg_client.h?ds=sidebyside diff --git a/projects/rlm_stg/stg_client.h b/projects/rlm_stg/stg_client.h index b90b0e60..917d0e51 100644 --- a/projects/rlm_stg/stg_client.h +++ b/projects/rlm_stg/stg_client.h @@ -18,71 +18,41 @@ * Author : Maxim Mamontov */ -#ifndef STG_CLIENT_H -#define STG_CLIENT_H +#ifndef __STG_RLM_CLIENT_H__ +#define __STG_RLM_CLIENT_H__ + +#include "types.h" #include "stg/os_int.h" #include #include -#include -#include - -typedef std::vector > PAIRS; -struct RESULT +namespace STG +{ +namespace RLM { - PAIRS modify; - PAIRS reply; -}; - -struct ChannelConfig { - struct Error : std::runtime_error { - Error(const std::string& message) : runtime_error(message) {} - }; - - ChannelConfig(std::string address); - - std::string transport; - std::string key; - std::string address; - std::string portStr; - uint16_t port; -}; -class STG_CLIENT +class Client { public: - enum TYPE { - AUTHORIZE, - AUTHENTICATE, - POST_AUTH, - PRE_ACCT, - ACCOUNT - }; - struct Error : std::runtime_error { - Error(const std::string& message) : runtime_error(message) {} - }; - - typedef bool (*Callback)(void* /*data*/, const RESULT& /*result*/, bool /*status*/); - - STG_CLIENT(const std::string& address, Callback callback, void* data); - STG_CLIENT(const STG_CLIENT& rhs); - ~STG_CLIENT(); + explicit Client(const std::string& address); + ~Client(); bool stop(); - bool connected() const; - static STG_CLIENT* get(); - static bool configure(const std::string& address, Callback callback, void* data); - static bool reconnect(); + static Client* get(); + static bool configure(const std::string& address); - bool request(TYPE type, const std::string& userName, const std::string& password, const PAIRS& pairs); + RESULT request(REQUEST_TYPE type, const std::string& userName, const std::string& password, const PAIRS& pairs); private: class Impl; boost::scoped_ptr m_impl; }; +} // namespace RLM +} // namespace STG + #endif