Skip to content
Snippets Groups Projects
Commit 9463c054 authored by Leon Dietrich's avatar Leon Dietrich
Browse files

chg: connection_client incomminb data cb to ptr of string

parent d6e0e92e
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ namespace rmrf::net {
class connection_client : public std::enable_shared_from_this<connection_client> {
public:
typedef std::function<void(std::string)> incomming_data_cb;
typedef std::function<void(std::shared_ptr<std::string>)> incomming_data_cb;
protected:
incomming_data_cb in_data_cb;
public:
......
......@@ -56,11 +56,11 @@ void tcp_client::write_data(std::string data) {
this->write_queue.push_back(std::make_shared<impl::NICBuffer>(data.c_str(), data.size()));
}
std::string buffer_to_string(char* buffer, ssize_t bufflen)
inline std::shared_ptr<std::string> buffer_to_string(char* buffer, ssize_t bufflen)
{
// For some wired reaseon the compiler refuses to find the correct constructor of string
// without this extra method.
std::string ret(buffer, (int) bufflen);
std::shared_ptr<std::string> ret = std::make_shared<std::string>(buffer, (int) bufflen);
return ret;
}
......
......@@ -53,6 +53,7 @@ private:
std::list<std::shared_ptr<impl::NICBuffer>> write_queue;
public:
tcp_client(const destructor_cb_type destructor_cb_, auto_fd&& socket_fd, std::string peer_address_, uint16_t port_);
tcp_client(const std::string);
virtual ~tcp_client();
virtual void write_data(std::string data);
std::string get_peer_address();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment