tufao  1.3.0
An asynchronous web framework for C++ built on top of Qt
Tufao::AbstractHttpUpgradeHandler Class Referenceabstract

This class provides an interface for HTTP Upgrade handlers. More...

+ Inheritance diagram for Tufao::AbstractHttpUpgradeHandler:
+ Collaboration diagram for Tufao::AbstractHttpUpgradeHandler:

Public Member Functions

 operator std::function< bool (HttpServerRequest &, const QByteArray &)>()
 Implicit conversion operator to std::function functor object. More...
 
 operator std::function< void (HttpServerRequest &, const QByteArray &)>()
 Implicit conversion operator to std::function functor object. More...
 
virtual bool handleUpgrade (Tufao::HttpServerRequest &request, const QByteArray &head)=0
 Handles the HTTP request. More...
 

Detailed Description

This class provides an interface for HTTP Upgrade handlers.

An upgrade handler is usually registered to handle requests matching some set of rules and usually used with a set of other handlers.

A sample upgrade handler is given below:

bool RequestHandler::handleUpgrade(Tufao::HttpServerRequest &request,
const QByteArray &head)
{
Tufao::WebSocket *socket = new Tufao::WebSocket(this);
socket->startServerHandshake(request, head);
connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
connect(socket, SIGNAL(newMessage(QByteArray)),
this, SIGNAL(newMessage(QByteArray)));
connect(this, SIGNAL(newMessage(QByteArray)),
socket, SLOT(sendMessage(QByteArray)));
return true;
}
See also
HttpUpgradeRouter
Since
0.6

Member Function Documentation

virtual bool Tufao::AbstractHttpUpgradeHandler::handleUpgrade ( Tufao::HttpServerRequest request,
const QByteArray &  head 
)
pure virtual

Handles the HTTP request.

Return values
trueIf the handler has upgraded the connection to the request protocol.
falseIf the handler didn't change the protocol to the requested one. The HTTP session should remain open (eg. a response message shouldn't be sent), leaving the response free to be used by other handlers in the chain.
Since
1.0
Tufao::AbstractHttpUpgradeHandler::operator std::function< bool ( HttpServerRequest ,
const QByteArray &   
)
inline

Implicit conversion operator to std::function functor object.

Warning
You shall not use the returned object after the AbstractHttpUpgradeHandler object is destroyed.
Since
1.0
Tufao::AbstractHttpUpgradeHandler::operator std::function< void ( HttpServerRequest ,
const QByteArray &   
)
inline

Implicit conversion operator to std::function functor object.

Note
The returned functor object calls handleUpgrade. If handleUpgrade returns false, then it will close the connection.
Warning
You shall not use the returned object after the AbstractHttpUpgradeHandler object is destroyed.
Since
1.0

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