ofxHTTP
A collection of tools for HTTP.
ofx::HTTP::SSEConnection Class Reference

A class representing a Server Sent Event Source with a single client. More...

#include <SSEConnection.h>

Inheritance diagram for ofx::HTTP::SSEConnection:
ofx::HTTP::BaseRouteHandler_< SSERoute > ofx::HTTP::AbstractRouteHandler ofx::HTTP::AbstractHTTPRequestHandler ofx::HTTP::AbstractServerEventRequestHandler

Public Member Functions

 SSEConnection (SSERoute &route)
 Create a SSEConnection. More...
 
virtual ~SSEConnection ()
 Destroy the SSEConnection.
 
void handleRequest (ServerEventArgs &evt) override
 Handle the ServerEventArgs. More...
 
void stop () override
 Interrupt the handleRequest method if possible.
 
bool send (const IndexedSSEFrame &frame) const
 Queue data to be sent to the client. More...
 
Poco::Net::NameValueCollection requestHeaders () const
 
Poco::Net::SocketAddress clientAddress () const
 
bool isConnected () const
 
std::size_t sendQueueSize () const
 
void clearSendQueue ()
 Clears the send queue.
 
std::size_t totalBytesSent () const
 Get the total bytes sent to the client. More...
 
- Public Member Functions inherited from ofx::HTTP::BaseRouteHandler_< SSERoute >
 BaseRouteHandler_ (SSERoute &route)
 Create a BaseRoute.
 
virtual ~BaseRouteHandler_ ()
 Destroy a BaseRoute.
 
void handleRequest (Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response) override
 
SSERouteroute ()
 Get the dispatching route.
 
- Public Member Functions inherited from ofx::HTTP::AbstractRouteHandler
virtual ~AbstractRouteHandler ()
 Destroy the AbstractRouteHandler 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.
 

Additional Inherited Members

- Protected Attributes inherited from ofx::HTTP::BaseRouteHandler_< SSERoute >
SSERoute_route
 The route.
 

Detailed Description

A class representing a Server Sent Event Source with a single client.

Frames can be sent across thread boundaries and are queued for sending during the SSERouteConnection's service loop. All accessors are synchronized and thread-safe.

Constructor & Destructor Documentation

◆ SSEConnection()

ofx::HTTP::SSEConnection::SSEConnection ( SSERoute route)

Create a SSEConnection.

Parameters
routeA reference to the parent SSERoute.

Member Function Documentation

◆ clientAddress()

Poco::Net::SocketAddress ofx::HTTP::SSEConnection::clientAddress ( ) const
Returns
the client's SocketAddress.

◆ handleRequest()

void ofx::HTTP::SSEConnection::handleRequest ( ServerEventArgs evt)
overridevirtual

Handle the ServerEventArgs.

Parameters
evtThe server request event.

Send the client retry interval.

Implements ofx::HTTP::BaseRouteHandler_< SSERoute >.

◆ isConnected()

bool ofx::HTTP::SSEConnection::isConnected ( ) const
Returns
true iff this SSEConnection is connected to a client.

◆ requestHeaders()

Poco::Net::NameValueCollection ofx::HTTP::SSEConnection::requestHeaders ( ) const
Returns
The original http request headers.

◆ send()

bool ofx::HTTP::SSEConnection::send ( const IndexedSSEFrame frame) const

Queue data to be sent to the client.

Parameters
frameThe data to send to the client.
cacheTrue if the frame should be cached.
Returns
false iff frame was not queued.

◆ sendQueueSize()

std::size_t ofx::HTTP::SSEConnection::sendQueueSize ( ) const
Returns
the size of the send queue.

◆ totalBytesSent()

std::size_t ofx::HTTP::SSEConnection::totalBytesSent ( ) const

Get the total bytes sent to the client.

Returns
the total bytes sent to the client.

The documentation for this class was generated from the following files: