1
This commit is contained in:
parent
9dad68d86f
commit
5d69655f43
@ -16,6 +16,12 @@
|
|||||||
|
|
||||||
const int PACK_MAX = 1024 * 64 * 2;
|
const int PACK_MAX = 1024 * 64 * 2;
|
||||||
|
|
||||||
|
#ifdef USE_ASIO
|
||||||
|
UpStream::UpStream(asio::io_context& io_context):socket_(io_context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void UpStream::Init(int instance_id, const std::string& remote_ip, int remote_port)
|
void UpStream::Init(int instance_id, const std::string& remote_ip, int remote_port)
|
||||||
{
|
{
|
||||||
if (remote_ip.empty()) {
|
if (remote_ip.empty()) {
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
#include <f8/protoutils.h>
|
#include <f8/protoutils.h>
|
||||||
|
|
||||||
|
#ifdef USE_ASIO
|
||||||
|
#include <asio.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace a8
|
namespace a8
|
||||||
{
|
{
|
||||||
class TcpClient;
|
class TcpClient;
|
||||||
@ -26,6 +30,10 @@ class UpStream
|
|||||||
a8::tick_t last_pong_tick = 0;
|
a8::tick_t last_pong_tick = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
#ifdef USE_ASIO
|
||||||
|
UpStream(asio::io_context& io_context);
|
||||||
|
#endif
|
||||||
|
|
||||||
void Init(int instance_id, const std::string& remote_ip, int remote_port);
|
void Init(int instance_id, const std::string& remote_ip, int remote_port);
|
||||||
void UnInit();
|
void UnInit();
|
||||||
|
|
||||||
@ -67,6 +75,9 @@ class UpStream
|
|||||||
char *recv_buff_ = nullptr;
|
char *recv_buff_ = nullptr;
|
||||||
unsigned int recv_bufflen_ = 0;
|
unsigned int recv_bufflen_ = 0;
|
||||||
std::shared_ptr<a8::TcpClient> tcp_client_;
|
std::shared_ptr<a8::TcpClient> tcp_client_;
|
||||||
|
#ifdef USE_ASIO
|
||||||
|
asio::ip::tcp::socket socket_;
|
||||||
|
#endif
|
||||||
f8::TimerWp timer_wp_;
|
f8::TimerWp timer_wp_;
|
||||||
f8::Attacher attacher_;
|
f8::Attacher attacher_;
|
||||||
|
|
||||||
|
@ -55,8 +55,12 @@ std::weak_ptr<UpStream> UpStreamMgr::RecreateUpStream(const std::string& host, i
|
|||||||
int instance_id = curr_id_;
|
int instance_id = curr_id_;
|
||||||
std::string remote_ip = host;
|
std::string remote_ip = host;
|
||||||
int remote_port = port;
|
int remote_port = port;
|
||||||
|
#ifdef USE_ASIO
|
||||||
|
asio::io_context io_context;
|
||||||
|
std::shared_ptr<UpStream> conn = std::make_shared<UpStream>(io_context);
|
||||||
|
#else
|
||||||
std::shared_ptr<UpStream> conn = std::make_shared<UpStream>();
|
std::shared_ptr<UpStream> conn = std::make_shared<UpStream>();
|
||||||
|
#endif
|
||||||
conn->Init(instance_id, remote_ip, remote_port);
|
conn->Init(instance_id, remote_ip, remote_port);
|
||||||
id_hash_[conn->instance_id] = conn;
|
id_hash_[conn->instance_id] = conn;
|
||||||
key_hash_[key] = conn;
|
key_hash_[key] = conn;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user