A WebSocket web application handler that routes to other handlers. More...
#include <RoutingWsWebApp.hpp>
Public Types | |
using | Node = Container::ObjectTrieNode< Value > |
The type of the routing nodes in the routing trie. More... | |
using | Routing = Container::ObjectTrie< Value > |
The type of the routing trie supplied to the routing handler constructor. More... | |
using | Value = std::tuple< std::string, WsWebAppPtr, WsWebAppPtr, WsWebAppPtr > |
The type of the routing node values added to the routing trie. More... | |
using | WsWebAppPtr = std::shared_ptr< WsWebApp > |
Shared pointer container for WebSocket web app instances. More... | |
Public Member Functions | |
RoutingWsWebApp (Routing &&routing_) | |
Construct a routing HTTP handler, by supplying a preformed routing trie. More... | |
void | handleBinaryMessage (WsSession &session, std::string_view path) override |
Handle received binary data. More... | |
void | handleClose (WsSession &session, std::string_view path) override |
Handle a received close control message. More... | |
void | handlePing (WsSession &session, std::string_view path) override |
Handle a received ping control message. More... | |
void | handlePong (WsSession &session, std::string_view path) override |
Handle a received pong control message. More... | |
void | handleTextMessage (WsSession &session, std::string_view path) override |
Handle received text data. More... | |
Public Member Functions inherited from WsWebApp | |
virtual | ~WsWebApp ()=default |
Destroy the WebSocket web application instance. More... | |
A WebSocket web application handler that routes to other handlers.
The routing handler works by selecting the most specific handler tuple for a particular path. If there is no match, not found is returned.
When the most specific handler tuple has been selected, the tuple's handler for the appropriate WebSocket message type is called.
If a most specific match is not suitable for all paths, the resolved handlers may nevertheless return not found / bad request responses for invalid paths.
In order to use the routing WebSocket handler, construct a routing trie, with each node containing a routing node. Routing nodes are std::tuple objects, the first element containing a string component in the path and the second, third, and fourth elements containing shared pointers of the handlers to route to for TODO TODO.
To construct the routing trie, the routingNode() convenience functions may be used. If the routing trie is fixed at compile time, the fluent API of the ObjectTrie class can be used to construct the routing.
As the handlers are kept in shared pointers, handler instances may be shared between multiple nodes in the trie if required.
using Node = Container::ObjectTrieNode<Value> |
The type of the routing nodes in the routing trie.
using Routing = Container::ObjectTrie<Value> |
The type of the routing trie supplied to the routing handler constructor.
using Value = std::tuple<std::string, WsWebAppPtr, WsWebAppPtr, WsWebAppPtr> |
The type of the routing node values added to the routing trie.
using WsWebAppPtr = std::shared_ptr<WsWebApp> |
Shared pointer container for WebSocket web app instances.
|
explicit |
Construct a routing HTTP handler, by supplying a preformed routing trie.
|
overridevirtual |
Handle received binary data.
Implements WsWebApp.
|
overridevirtual |
Handle a received close control message.
Implements WsWebApp.
|
overridevirtual |
Handle a received ping control message.
Implements WsWebApp.
|
overridevirtual |
Handle a received pong control message.
Implements WsWebApp.
|
overridevirtual |
Handle received text data.
Implements WsWebApp.