You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

67 lines
1.4 KiB

/*
* @Description:
* @Version: 1.0
* @Autor: lishengyin
* @Date: 2022-04-11 17:30:58
* @LastEditors: Please set LastEditors
* @LastEditTime: 2022-04-11 23:14:30
*/
#ifndef __TCPPROXYSESSION_HPP_
#define __TCPPROXYSESSION_HPP_
#include <iostream>
#include <signal.h>
#include "Util/logger.h"
#include "Util/NoticeCenter.h"
#include "UserApp.hpp"
#include "Network/TcpServer.h"
#include "Network/TcpSession.h"
#include <vector>
#include <map>
using namespace std;
using namespace toolkit;
class TcpProxySession;
class ProxySessions
{
public:
std::string NameId;
std::shared_ptr<TcpProxySession> session = nullptr;
public:
ProxySessions(){}
~ProxySessions(){}
};
class TcpProxySession: public TcpSession {
public:
TcpProxySession(const Socket::Ptr &sock) :
TcpSession(sock) {
DebugL;
}
~TcpProxySession() {
DebugL;
}
virtual void onRecv(const Buffer::Ptr &buf) override{
//处理客户端发送过来的数据
TraceL << buf->data() << " from port:" << getIdentifier();
}
virtual void onError(const SockException &err) override{
//客户端断开连接或其他原因导致该对象脱离TCPServer管理
WarnL << err.what();
}
virtual void onManager() override{
//定时管理该对象,譬如会话超时检查
// DebugL;
}
private:
Ticker _ticker;
};
#endif