diff options
| author | Per Larsson <[email protected]> | 2022-02-18 09:31:22 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-02-18 09:31:22 +0100 |
| commit | b063a8c2fccbdbf73e1a7730cf26a97cec475636 (patch) | |
| tree | 0ce59ad2c72a33a5592bc32bfb75ad3b6f00e0fb /zenhttp/include | |
| parent | Simple websocket client/server test. (diff) | |
| download | zen-b063a8c2fccbdbf73e1a7730cf26a97cec475636.tar.xz zen-b063a8c2fccbdbf73e1a7730cf26a97cec475636.zip | |
Route websocket message.
Diffstat (limited to 'zenhttp/include')
| -rw-r--r-- | zenhttp/include/zenhttp/websocket.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/zenhttp/include/zenhttp/websocket.h b/zenhttp/include/zenhttp/websocket.h index eb4920f17..c08affb98 100644 --- a/zenhttp/include/zenhttp/websocket.h +++ b/zenhttp/include/zenhttp/websocket.h @@ -11,6 +11,8 @@ class io_context; namespace zen { +class CbPackage; + struct WebSocketServerOptions { uint16_t Port = 8848; @@ -31,15 +33,15 @@ public: enum class WebSocketState : uint32_t { kNone, - kConnecting, + kHandshaking, kConnected, kDisconnected, - kFailedToConnect + kError }; enum class WebSocketEvent : uint32_t { - kInvalid, + kNone, kConnected, kDisconnected, kError @@ -57,7 +59,8 @@ struct WebSocketConnectInfo class WebSocketClient { public: - using EventCallback = std::function<void()>; + using EventCallback = std::function<void()>; + using MessageCallback = std::function<void(CbPackage&)>; virtual ~WebSocketClient() = default; @@ -67,6 +70,7 @@ public: virtual WebSocketState State() const = 0; virtual void On(WebSocketEvent Evt, EventCallback&& Cb) = 0; + virtual void OnMessage(MessageCallback&& Cb) = 0; static std::unique_ptr<WebSocketClient> Create(asio::io_context& IoCtx); }; |