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.
|
|
|
/*
|
|
|
|
* @Description:
|
|
|
|
* @Version: 1.0
|
|
|
|
* @Autor: lishengyin
|
|
|
|
* @Date: 2022-04-11 17:12:05
|
|
|
|
* @LastEditors: Please set LastEditors
|
|
|
|
* @LastEditTime: 2022-04-11 23:12:33
|
|
|
|
*/
|
|
|
|
#ifndef __USERAPP_HPP_
|
|
|
|
#define __USERAPP_HPP_
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <atomic>
|
|
|
|
#include <bitset>
|
|
|
|
#include <functional>
|
|
|
|
#include <list>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <thread>
|
|
|
|
#include <typeinfo>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <utility>
|
|
|
|
#include "Network/TcpServer.h"
|
|
|
|
#include "Network/TcpSession.h"
|
|
|
|
#include "TcpProxySession.hpp"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace toolkit;
|
|
|
|
|
|
|
|
#define OK 0
|
|
|
|
#define ERR -1
|
|
|
|
|
|
|
|
// NonCopyAble
|
|
|
|
class NonCopyable {
|
|
|
|
protected:
|
|
|
|
NonCopyable() {};
|
|
|
|
~NonCopyable() {};
|
|
|
|
|
|
|
|
public:
|
|
|
|
NonCopyable(const NonCopyable&) = delete;
|
|
|
|
NonCopyable(NonCopyable&&) = delete;
|
|
|
|
NonCopyable& operator=(const NonCopyable&) = delete;
|
|
|
|
NonCopyable& operator=(NonCopyable&&) = delete;
|
|
|
|
|
|
|
|
static std::string getDataTime(){
|
|
|
|
char ctime[80];
|
|
|
|
time_t rawtime;
|
|
|
|
struct tm *info;
|
|
|
|
time(&rawtime);
|
|
|
|
info = localtime(&rawtime);
|
|
|
|
strftime(ctime, 80, "%Y-%m-%d %H:%M:%S", info);
|
|
|
|
std::string DataTime = ctime;
|
|
|
|
return DataTime;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class UserApp:private NonCopyable
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
UserApp(std::string appName):appName_(appName){}
|
|
|
|
public:
|
|
|
|
using Ptr = std::shared_ptr<UserApp>;
|
|
|
|
|
|
|
|
~UserApp(){}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description: 创建新的实例
|
|
|
|
* @param {string} appName
|
|
|
|
* @return {*}
|
|
|
|
*/
|
|
|
|
static std::shared_ptr<UserApp> CreateNew(std::string appName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description: 初始化
|
|
|
|
* @param {*}
|
|
|
|
* @return {*}
|
|
|
|
*/
|
|
|
|
int8_t Init();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description: 启动任务
|
|
|
|
* @param {*}
|
|
|
|
* @return {*}
|
|
|
|
*/
|
|
|
|
int8_t StartTask();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string appName_;
|
|
|
|
int port = 7400;
|
|
|
|
|
|
|
|
TcpServer::Ptr m_tcpServer = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|