Class WebSocketController

Synopsis

#include <lib/inc/drogon/WebSocketController.h>

template <typename T, bool AutoCreation = true>
class WebSocketController : public DrObject<T>, public WebSocketControllerBase

Description

The reflection base class template for WebSocket controllers.

Template Parameters:

T - the type of the implementation class

AutoCreation - The flag for automatically creating, user can set this flag to false for classes that have nondefault constructors.

Mentioned in

Inheritance

Ancestors: DrObject, WebSocketControllerBase

Methods

WebSocketController
~WebSocketController
registerSelf__

Source

Lines 69-111 in lib/inc/drogon/WebSocketController.h.

template <typename T, bool AutoCreation = true>
class WebSocketController : public DrObject<T>, public WebSocketControllerBase
{
  public:
    static const bool isAutoCreation = AutoCreation;
    virtual ~WebSocketController()
    {
    }

  protected:
    WebSocketController()
    {
    }
    static void registerSelf__(
        const std::string &path,
        const std::vector<internal::HttpConstraint> &filtersAndMethods)
    {
        LOG_TRACE << "register websocket controller("
                  << WebSocketController<T>::classTypeName()
                  << ") on path:" << path;
        app().registerWebSocketController(
            path, WebSocketController<T>::classTypeName(), filtersAndMethods);
    }

  private:
    class pathRegistrator
    {
      public:
        pathRegistrator()
        {
            if (AutoCreation)
            {
                T::initPathRouting();
            }
        }
    };
    friend pathRegistrator;
    static pathRegistrator registrator_;
    virtual void *touch()
    {
        return &registrator_;
    }
};





Add Discussion as Guest

Log in