X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/e5499c61083684b28bcbc6950aae66cbf0938703..e9ae1f101b5418c0ba2e6c9d86b23c12f0140982:/libs/srvconf/netunit.h diff --git a/libs/srvconf/netunit.h b/libs/srvconf/netunit.h index 34d730e1..66d95c3d 100644 --- a/libs/srvconf/netunit.h +++ b/libs/srvconf/netunit.h @@ -18,58 +18,56 @@ * Author : Boris Mikhailenko */ -#ifndef NetUnitH -#define NetUnitH - -#include +#pragma once #include +#include namespace STG { -class NETTRANSACT +class NetTransact { -public: - typedef bool (* CALLBACK)(const std::string &, bool, void *); + public: + using Callback = bool (*)(const std::string&, bool, void *); - NETTRANSACT(const std::string & server, uint16_t port, - const std::string & login, const std::string & password); - NETTRANSACT(const std::string & server, uint16_t port, - const std::string & localAddress, uint16_t localPort, - const std::string & login, const std::string & password); - ~NETTRANSACT(); - int Transact(const std::string & request, CALLBACK f, void * data); - const std::string & GetError() const { return errorMsg; } + NetTransact(const std::string& server, uint16_t port, + const std::string& login, const std::string& password); + NetTransact(const std::string& server, uint16_t port, + const std::string& localAddress, uint16_t localPort, + const std::string& login, const std::string& password); + ~NetTransact(); - int Connect(); - void Disconnect(); -private: - int TxHeader(); - int RxHeaderAnswer(); + int Transact(const std::string& request, Callback f, void* data); + const std::string & GetError() const { return errorMsg; } - int TxLogin(); - int RxLoginAnswer(); + int Connect(); + void Disconnect(); - int TxLoginS(); - int RxLoginSAnswer(); + private: + int TxHeader(); + int RxHeaderAnswer(); - int TxData(const std::string & text); - int RxDataAnswer(CALLBACK f, void * data); + int TxLogin(); + int RxLoginAnswer(); - std::string server; - uint16_t port; - std::string localAddress; - uint16_t localPort; - std::string login; - std::string password; - int sock; - std::string errorMsg; + int TxLoginS(); + int RxLoginSAnswer(); - static bool TxCrypto(const void * block, size_t size, void * data); - static bool RxCrypto(const void * block, size_t size, void * data); + int TxData(const std::string& text); + int RxDataAnswer(Callback f, void* data); + + std::string server; + uint16_t port; + std::string localAddress; + uint16_t localPort; + std::string login; + std::string password; + int sock; + std::string errorMsg; + + static bool TxCrypto(const void * block, size_t size, void * data); + static bool RxCrypto(const void * block, size_t size, void * data); }; } // namespace STG - -#endif