代码拉取完成,页面将自动刷新
#pragma once
/*
*/
#include <string>
#include <memory>
#include <functional>
#include "eventloop.h"
#include "channel.h"
#include "log.h"
enum ConnectionState{
H_CONNECTED=0,
H_DISCONNECTING,
H_DISCONNECTED
};
class TcpConnection{
public:
TcpConnection(EventLoop *p, int fd);
~TcpConnection(){
close(m_connfd);
}
EventLoop* getLoop();
void handleClose();
void set_event(uint32_t);
void register_event();
std::string& getInbuffer(){
return m_inBuffer;
}
void setOutbuffer(const std::string &str){
m_outBuffer=str;
}
void clearAndError(){
record()<<"m_error change to true";
m_error=true;
m_inBuffer.clear();
m_outBuffer.clear();
}
std::shared_ptr<Channel> getChannel(){
return m_channel_ptr;
}
public:
void handleRead();
void handleWrite();
void handleError();
void handleConn();
void setCall(std::function<int()>&& func){
m_callback=func;
}
void setSeperate(std::function<void()>&& func){
m_seperate=func;
}
private:
EventLoop *m_loop;
int m_connfd;
std::shared_ptr<Channel> m_channel_ptr;
std::string m_inBuffer;
std::string m_outBuffer;
ConnectionState m_conn_state;
bool m_error;
std::function<int()> m_callback;
//?
std::function<void()> m_seperate;
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。