1
This commit is contained in:
parent
48a3cd1cdd
commit
f937b70cca
@ -24,7 +24,7 @@ void Master::Init(int instance_id, const std::string& remote_ip, int remote_port
|
||||
recv_bufflen_ = 0;
|
||||
last_pong_tick = a8::XGetTickCount();
|
||||
recv_buff_ = (char*) malloc(PACK_MAX * 2);
|
||||
tcp_client_ = new a8::TcpClient();
|
||||
tcp_client_ = std::make_shared<a8::TcpClient>();
|
||||
tcp_client_->remote_address = remote_ip;
|
||||
tcp_client_->remote_port = remote_port;
|
||||
tcp_client_->on_error = std::bind(&Master::on_error, this, std::placeholders::_1, std::placeholders::_2);
|
||||
@ -48,7 +48,9 @@ void Master::UnInit()
|
||||
f8::Timer::Instance()->Delete(timer_wp_);
|
||||
}
|
||||
tcp_client_->Close();
|
||||
delete tcp_client_;
|
||||
if (tcp_client_.use_count() != 1) {
|
||||
abort();
|
||||
}
|
||||
tcp_client_ = nullptr;
|
||||
recv_bufflen_ = 0;
|
||||
free(recv_buff_);
|
||||
|
@ -27,7 +27,7 @@ class Master
|
||||
void SendMsg(T& msg)
|
||||
{
|
||||
static int msgid = f8::Net_GetMessageId(msg);
|
||||
f8::Net_SendMsg(tcp_client_, 0, msgid, msg);
|
||||
f8::Net_SendMsg(tcp_client_.get(), 0, msgid, msg);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -41,7 +41,7 @@ class Master
|
||||
private:
|
||||
char *recv_buff_ = nullptr;
|
||||
unsigned int recv_bufflen_ = 0;
|
||||
a8::TcpClient* tcp_client_ = nullptr;
|
||||
std::shared_ptr<a8::TcpClient> tcp_client_;
|
||||
f8::TimerWp timer_wp_;
|
||||
f8::Attacher attacher_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user