2025-07-18 09:08:09 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
#include "common/Fields.h"
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
|
|
|
|
|
class CommEntity
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CommEntity() {}
|
|
|
|
|
|
CommEntity(std::string type) : type(type) {}
|
|
|
|
|
|
|
2025-08-28 18:42:37 +08:00
|
|
|
|
static std::shared_ptr<CommEntity> create(Fields& data);
|
|
|
|
|
|
|
2025-07-18 09:08:09 +08:00
|
|
|
|
void setType(std::string type) { this->type = type; }
|
|
|
|
|
|
|
|
|
|
|
|
// 启动通讯连接
|
|
|
|
|
|
virtual int start() { return 0; };
|
|
|
|
|
|
// 关闭通讯连接
|
2025-08-31 14:38:53 +08:00
|
|
|
|
virtual void close() { isCloseRequest = true; };
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
|
|
|
|
|
std::string id() { return id_; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
std::string id_;
|
|
|
|
|
|
std::string type;
|
2025-08-31 14:38:53 +08:00
|
|
|
|
int commtype = 0;
|
|
|
|
|
|
bool alive = false;
|
|
|
|
|
|
bool isConnected = false;
|
|
|
|
|
|
bool isCloseRequest = false;
|
2025-07-18 09:08:09 +08:00
|
|
|
|
};
|