1 Star 0 Fork 32

feiyuluyan/CM-Server

forked from 留天下/CM-Server 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
networkmanager.h 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
留天下 提交于 2019-02-22 13:22 . net redo done!
#ifndef NETWORKMANAGER_H
#define NETWORKMANAGER_H
#include"tool.h"
#include"signal.h"
#include"cmserver.h"
#include<atomic>
#include<mutex>
#include<map>
#define NET_INSTANCE NetWorkManager::getInstance
#define NET_SOCKET NetWorkManager::getInstance()->getSocketManager
using NetMsg = Json::Value;
class NetWorkManager
{
GET_SINGLE_OBJECT(NetWorkManager)
public:
NetWorkManager(const NetWorkManager&) = delete;
NetWorkManager& operator=(const NetWorkManager&) = delete;
void startServer();
Slot* add(const int& messageId, const EventHandler& evHandler);
Slot* add(const int& messageId, const std::function<void(Json::Value&)>&);
void dispatch(const int& messageId,Json::Value& message);
void send(const int& fd,const int & messageId, const std::map<std::string, std::string>& msg);
void send(const int& fd,const int & messageId, Json::Value& msg);
PROPERTY__REF(int,m_fd,Fd)
PROPERTY__REF(CMServer,m_socketManager,SocketManager)
private:
NetWorkManager();
~NetWorkManager() {}
std::map<int, Signal> m_signals;
int m_curfd;
SINGLE_ATTRIBUTES(NetWorkManager);
};
#endif // NETWORKMANAGER_H
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/feiyuluyan/CM-Server.git
[email protected]:feiyuluyan/CM-Server.git
feiyuluyan
CM-Server
CM-Server
master

搜索帮助