ofxHTTP
A collection of tools for HTTP.
|
A route for handling WebSockets. More...
#include <SSERoute.h>
Public Types | |
typedef SSERouteSettings | Settings |
A typedef for the SSERouteSettings. | |
Public Member Functions | |
SSERoute (const Settings &settings) | |
Create a SSERoute with the given Settings. More... | |
virtual | ~SSERoute () |
Destroy the SSERoute. | |
virtual bool | canHandleRequest (const Poco::Net::HTTPServerRequest &request, bool isSecurePort) const override |
Determine if this route can handle the given request. More... | |
virtual Poco::Net::HTTPRequestHandler * | createRequestHandler (const Poco::Net::HTTPServerRequest &request) override |
Creates a new HTTPRequestHandler for the given request. More... | |
virtual void | stop () override |
Stop any pending activity and close this route. More... | |
void | send (const std::string &data, bool cache=false) |
Send a SSEFrame to all connections. More... | |
void | send (const std::string &event, const std::string &data, bool cache=false) |
Send a SSEFrame to all connections. More... | |
void | send (const SSEFrame &frame, bool cache=false) |
Send a SSEFrame to all connected connections. More... | |
std::size_t | numConnections () const |
std::size_t | frameCacheSize () const |
void | clearFrameCache () |
Clears the frame cache. | |
template<class ListenerClass > | |
void | registerEventListeners (ListenerClass *listener, int priority=OF_EVENT_ORDER_AFTER_APP) |
Register event listeners for this route. More... | |
template<class ListenerClass > | |
void | unregisterEventListeners (ListenerClass *listener, int priority=OF_EVENT_ORDER_AFTER_APP) |
Unregister event listeners for this route. More... | |
Public Member Functions inherited from ofx::HTTP::BaseRoute_< SSERouteSettings > | |
BaseRoute_ (const SSERouteSettings &settings=SSERouteSettings()) | |
Create a BaseRoute. More... | |
virtual | ~BaseRoute_ () |
Destroy a BaseRoute. | |
virtual void | setup (const SSERouteSettings &settings) |
Setup the route with settings. More... | |
virtual std::string | routePathPattern () const override |
Get the route's regex path pattern. More... | |
void | handleRequest (Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response) override |
virtual void | handleRequest (ServerEventArgs &evt) override |
Handle the ServerEventArgs. More... | |
const SSERouteSettings & | settings () const |
AbstractServer * | getServer () override |
void | setServer (AbstractServer *server) override |
Set the server that owns this route. More... | |
Public Member Functions inherited from ofx::HTTP::AbstractRoute | |
virtual | ~AbstractRoute () |
Destroy the AbstractRoute instance. | |
Public Member Functions inherited from ofx::HTTP::AbstractHTTPRequestHandler | |
virtual | ~AbstractHTTPRequestHandler () |
Destroy the AbstractHTTPRequestHandler. | |
Public Member Functions inherited from ofx::HTTP::AbstractServerEventRequestHandler | |
virtual | ~AbstractServerEventRequestHandler () |
Destroy the AbstractServerEventRequestHandler. | |
Public Member Functions inherited from ofx::HTTP::AbstractHTTPRequestHandlerFactory | |
virtual | ~AbstractHTTPRequestHandlerFactory () |
Destroy the AbstractHTTPRequestHandlerFactory. | |
Public Attributes | |
SSEEvents | events |
SSEEvents for SSE callbacks. | |
Friends | |
class | SSEConnection |
Additional Inherited Members | |
Protected Attributes inherited from ofx::HTTP::BaseRoute_< SSERouteSettings > | |
SSERouteSettings | _settings |
The settings. | |
AbstractServer * | _server |
A pointer to the server. | |
A route for handling WebSockets.
ofx::HTTP::SSERoute::SSERoute | ( | const Settings & | settings | ) |
Create a SSERoute with the given Settings.
settings | The WebSocketRoute settings. |
|
overridevirtual |
Determine if this route can handle the given request.
request | The incoming Poco::Net::HTTPServerRequest to be tested. |
isSecurePort | true iff the connection is SSL encrypted. Some implmenetations of this interface may choose to only handle requests on secure ports. |
Reimplemented from ofx::HTTP::BaseRoute_< SSERouteSettings >.
|
overridevirtual |
Creates a new HTTPRequestHandler for the given request.
Before this is called, it is expected that the calling server has confirmed that this route is capable of handling the request by calling canHandleRequest().
request | The HTTPServerRequest to be passed to the handler. |
Reimplemented from ofx::HTTP::BaseRoute_< SSERouteSettings >.
std::size_t ofx::HTTP::SSERoute::frameCacheSize | ( | ) | const |
std::size_t ofx::HTTP::SSERoute::numConnections | ( | ) | const |
void ofx::HTTP::SSERoute::registerEventListeners | ( | ListenerClass * | listener, |
int | priority = OF_EVENT_ORDER_AFTER_APP |
||
) |
Register event listeners for this route.
The listener class must implement the following callbacks:
onSSEOpenEvent(...), onSSECloseEvent(...), onSSEFrameSentEvent(...).
ListenerClass | The lister class to register. |
listener | A pointer to the listener class. |
priority | The listener priority. |
void ofx::HTTP::SSERoute::send | ( | const std::string & | data, |
bool | cache = false |
||
) |
Send a SSEFrame to all connections.
data | The frame to send. |
cache | True if the frame should be indexed and cached. |
void ofx::HTTP::SSERoute::send | ( | const std::string & | event, |
const std::string & | data, | ||
bool | cache = false |
||
) |
Send a SSEFrame to all connections.
event | The event name to send. |
data | The frame to send. |
cache | True if the frame should be indexed and cached. |
void ofx::HTTP::SSERoute::send | ( | const SSEFrame & | frame, |
bool | cache = false |
||
) |
Send a SSEFrame to all connected connections.
frame | The frame to send. |
cache | True if the frame should be indexed and cached. |
|
overridevirtual |
Stop any pending activity and close this route.
This method may block until the route is fully stopped.
Reimplemented from ofx::HTTP::BaseRoute_< SSERouteSettings >.
void ofx::HTTP::SSERoute::unregisterEventListeners | ( | ListenerClass * | listener, |
int | priority = OF_EVENT_ORDER_AFTER_APP |
||
) |
Unregister event listeners for this route.
ListenerClass | The lister class to uregister. |
listener | A pointer to the listener class. |
priority | The listener priority. |