diff --git a/examples/echo_client/main.cpp b/examples/echo_client/main.cpp index b2bfd7e..aa00df5 100644 --- a/examples/echo_client/main.cpp +++ b/examples/echo_client/main.cpp @@ -31,7 +31,7 @@ void startClients(uv::EventLoop* loop,uv::SocketAddr& addr,std::vectorsetMessageCallback([client](const char* data,ssize_t size) { - client->write(data,size,nullptr); + client->write(data,(unsigned)size,nullptr); }); client->connect(addr); diff --git a/uv/TcpClient.cpp b/uv/TcpClient.cpp index ceb44ba..bebc159 100755 --- a/uv/TcpClient.cpp +++ b/uv/TcpClient.cpp @@ -108,22 +108,21 @@ void TcpClient::onMessage(shared_ptr connection,const char* buf,s onMessageCallback_(buf,size); } -void uv::TcpClient::close(std::function callback) +void uv::TcpClient::close(std::function callback) { if (connection_) { - connection_->close([this, callback](std::string& name) + connection_->close([this, callback](std::string&) { //onClose(name); if (callback) - callback(name); + callback(this); }); } else if(callback) { - std::string str(""); - callback(str); + callback(this); } } diff --git a/uv/http/HttpClient.cpp b/uv/http/HttpClient.cpp index 05f6fe9..8b50692 100755 --- a/uv/http/HttpClient.cpp +++ b/uv/http/HttpClient.cpp @@ -25,8 +25,7 @@ HttpClient::~HttpClient() { if (isConnected) { - auto client = client_; - client->close([client](std::string& name) + client_->close([](uv::TcpClient* client) { delete client; }); diff --git a/uv/include/TcpClient.h b/uv/include/TcpClient.h index a1bf3b9..cf3f203 100755 --- a/uv/include/TcpClient.h +++ b/uv/include/TcpClient.h @@ -43,7 +43,7 @@ class TcpClient void onConnect(bool successed); void onConnectClose(std::string& name); void onMessage(TcpConnectionPtr connection,const char* buf,ssize_t size); - void close(std::function callback); + void close(std::function callback); void afterConnectFail(); void write(const char* buf, unsigned int size, AfterWriteCallback callback = nullptr);