web_server 初步改

This commit is contained in:
2026-08-21 12:26:54 +08:00
parent 8499ae4555
commit d1aa763fcd
4 changed files with 54 additions and 1 deletions
+6
View File
@@ -1,7 +1,9 @@
#pragma once
#include "Graph_Session.hpp"
#include <drogon/WebSocketController.h>
#include <functional>
#include <memory>
#include <string>
namespace aethera::web {
class Graph_WebSocket final : public std::enable_shared_from_this<Graph_WebSocket> {
public:
@@ -9,9 +11,13 @@ public:
~Graph_WebSocket();
Graph_WebSocket(const Graph_WebSocket&) = delete;
Graph_WebSocket& operator=(const Graph_WebSocket&) = delete;
using Callback = std::function<void(std::string_view)>;
void start();
void receive(std::string_view message);
void close();
void register_callback(std::string key, Callback callback);
void unregister_callback(std::string_view key);
void send(std::string_view key, std::string_view frame);
private:
struct Private;
std::unique_ptr<Private> d; /* Drogon 连接与图会话绑定。 */