ofxHTTP
A collection of tools for HTTP.
ofx::HTTP::BaseConnection_< RouteType, FrameType > Class Template Reference
Inheritance diagram for ofx::HTTP::BaseConnection_< RouteType, FrameType >:
ofx::HTTP::BaseRouteHandler_< RouteType > ofx::HTTP::AbstractRouteHandler ofx::HTTP::AbstractHTTPRequestHandler ofx::HTTP::AbstractServerEventRequestHandler

Public Member Functions

 BaseConnection_ (RouteType &route)
 Create a BaseConnection_. More...
 
virtual ~BaseConnection_ ()
 Destroy the BaseConnection_.
 
void handleRequest (ServerEventArgs &evt) override
 Handle the ServerEventArgs. More...
 
void stop () override
 Interrupt the handleRequest method if possible.
 
bool send (const FrameType &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_< RouteType >
 BaseRouteHandler_ (RouteType &route)
 Create a BaseRoute.
 
virtual ~BaseRouteHandler_ ()
 Destroy a BaseRoute.
 
void handleRequest (Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response) override
 
RouteType & route ()
 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.
 

Protected Attributes

Poco::Net::NameValueCollection _requestHeaders
 The original request headers for reference.
 
Poco::Net::SocketAddress _clientAddress
 The client's SocketAddress for reference.
 
bool _isConnected = false
 True iff the BaseConnection_ is connected to a client.
 
std::size_t _totalBytesSent = 0
 The total number of bytes sent to the client.
 
std::queue< FrameType > _frameQueue
 A queue of the SSEFrames scheduled for delivery.
 
std::mutex _mutex
 A mutex for threadsafe access to the frame queue, etc.
 
- Protected Attributes inherited from ofx::HTTP::BaseRouteHandler_< RouteType >
RouteType & _route
 The route.
 

Constructor & Destructor Documentation

◆ BaseConnection_()

template<typename RouteType , typename FrameType >
ofx::HTTP::BaseConnection_< RouteType, FrameType >::BaseConnection_ ( RouteType &  route)

Create a BaseConnection_.

Parameters
routeA reference to the parent route.

Member Function Documentation

◆ clientAddress()

template<typename RouteType , typename FrameType >
Poco::Net::SocketAddress ofx::HTTP::BaseConnection_< RouteType, FrameType >::clientAddress ( ) const
Returns
the client's SocketAddress.

◆ handleRequest()

template<typename RouteType , typename FrameType >
void ofx::HTTP::BaseConnection_< RouteType, FrameType >::handleRequest ( ServerEventArgs evt)
overridevirtual

Handle the ServerEventArgs.

Parameters
evtThe server request event.

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

◆ isConnected()

template<typename RouteType , typename FrameType >
bool ofx::HTTP::BaseConnection_< RouteType, FrameType >::isConnected ( ) const
Returns
true iff this BaseConnection_ is connected to a client.

◆ requestHeaders()

template<typename RouteType , typename FrameType >
Poco::Net::NameValueCollection ofx::HTTP::BaseConnection_< RouteType, FrameType >::requestHeaders ( ) const
Returns
The original http request headers.

◆ send()

template<typename RouteType , typename FrameType >
bool ofx::HTTP::BaseConnection_< RouteType, FrameType >::send ( const FrameType &  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()

template<typename RouteType , typename FrameType >
std::size_t ofx::HTTP::BaseConnection_< RouteType, FrameType >::sendQueueSize ( ) const
Returns
the size of the send queue.

◆ totalBytesSent()

template<typename RouteType , typename FrameType >
std::size_t ofx::HTTP::BaseConnection_< RouteType, FrameType >::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 file: