This commit is contained in:
aozhiwei 2023-05-28 09:13:38 +08:00
parent c4042dbd5b
commit 548150779d
4 changed files with 55 additions and 2 deletions

View File

@ -8,7 +8,7 @@
#include <a8/a8.h>
#include <a8/asiotcpclient.h>
#ifdef USE_ASIO
#ifdef USE_BOOST
const int MAX_RECV_BUFFERSIZE = 1024 * 64;

View File

@ -1,6 +1,6 @@
#pragma once
#ifdef USE_ASIO
#ifdef USE_BOOST
#include <asio.hpp>

25
a8/websocketclient.cc Normal file
View File

@ -0,0 +1,25 @@
#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): 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;
}
}
#endif

28
a8/websocketclient.h Normal file
View File

@ -0,0 +1,28 @@
#pragma once
#include <a8/asiotcpclient.h>
#ifdef USE_BOOST
#include <asio.hpp>
using asio::ip::tcp;
namespace a8
{
class WebSocketClient : public AsioTcpClient
{
public:
WebSocketClient(asio::io_context& io_context, const std::string& remote_ip, int remote_port);
virtual ~WebSocketClient() override;
private:
char *decoded_buff_ = nullptr;
int decoded_bufflen_ = 0;
bool handshook_ = false;
};
}
#endif