19 Star 44 Fork 32

留天下 / 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
C++
1
https://gitee.com/lsylovews/CM-Server.git
git@gitee.com:lsylovews/CM-Server.git
lsylovews
CM-Server
CM-Server
master

搜索帮助