首次提交
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/Base/global_include.h"
|
||||
#include "Core/socket/ByteOrder.h"
|
||||
|
||||
#include <drogon/WebSocketConnection.h>
|
||||
#include <drogon/WebSocketController.h>
|
||||
|
||||
|
||||
|
||||
class WebSocket_Manager {
|
||||
public:
|
||||
explicit WebSocket_Manager(std::string path);
|
||||
~WebSocket_Manager() = default;
|
||||
void remove(const drogon::WebSocketConnectionPtr &conn);
|
||||
void add(const drogon::WebSocketConnectionPtr &conn);
|
||||
void visit(const std::function<void(const drogon::WebSocketConnectionPtr &conn)> &func);
|
||||
void push_data(const char *buf, uint64_t len);
|
||||
size_t get_websocket_connect_num();
|
||||
std::string path;
|
||||
protected:
|
||||
std::mutex mtx;
|
||||
std::unordered_set<drogon::WebSocketConnectionPtr> connections;
|
||||
};
|
||||
|
||||
|
||||
class Ws_Mgr : public Psc::Singleton<Ws_Mgr> {
|
||||
public:
|
||||
std::shared_ptr<WebSocket_Manager> register_ws(std::string path);
|
||||
std::shared_ptr<WebSocket_Manager> get_ws(std::string path);
|
||||
std::map<std::string, std::shared_ptr<WebSocket_Manager>> map;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user