a8/a8/websocketclient.cc
aozhiwei afdc699fb7 1
2023-05-28 09:38:05 +08:00

54 lines
1.0 KiB
C++

#include <a8/a8.h>
#include <a8/websocketclient.h>
#ifdef USE_BOOST
namespace a8
{
WebSocketClient::WebSocketClient(asio::io_context& io_context, const std::string& remote_ip, int remote_port)
{
tcp_client_ = std::make_shared<AsioTcpClient>(io_context, remote_ip, remote_port);
decoded_buff_ = (char *)malloc(1024 * 64 + 1);
decoded_bufflen_ = 0;
}
WebSocketClient::~WebSocketClient()
{
free(decoded_buff_);
decoded_buff_ = nullptr;
decoded_bufflen_ = 0;
}
void WebSocketClient::Open()
{
tcp_client_->Open();
}
void WebSocketClient::Close()
{
tcp_client_->Close();
}
bool WebSocketClient::IsActive()
{
return tcp_client_->IsActive();
}
bool WebSocketClient::Connected()
{
return tcp_client_->Connected();
}
void WebSocketClient::SendBuff(const char* buff, unsigned int bufflen)
{
if (!handshook_) {
abort();
}
}
}
#endif