morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::UiService Class Referencefinal

The UI service: answers ui-hello, ui-catalog and ui-fetch from one ServedBundle, and ui-evaluate through the server's ActionDispatcher, as an envelope service of a RemoteServer (ServerConfig::services). More...

#include <service.hpp>

Inheritance diagram for morph::ui::UiService:
morph::backend::IEnvelopeService

Public Member Functions

 UiService (std::shared_ptr< ServedBundle const > bundle, ::morph::model::detail::ActionDispatcher &dispatcher=::morph::model::detail::defaultDispatcher(), std::shared_ptr< IFileStore > files=nullptr)
 Serves bundle, and evaluates through dispatcher.
bool serves (std::string_view kind) const override
 Whether kind is one of the service's kinds.
std::string handle (::morph::wire::Envelope const &request, ::morph::session::IAuthorizer const &authorizer) override
 Answers one request with no connection behind it: a ui-hello offer of events is accepted in the reply, and recorded nowhere.
std::string handle (::morph::wire::Envelope const &request, ::morph::session::IAuthorizer const &authorizer, ::morph::backend::ConnectionFacts &facts) override
 Answers one request; a ui-hello that offers events and is answered ok sets facts.events.
Public Member Functions inherited from morph::backend::IEnvelopeService
 IEnvelopeService (const IEnvelopeService &)=delete
IEnvelopeService & operator= (const IEnvelopeService &)=delete
 IEnvelopeService (IEnvelopeService &&)=delete
IEnvelopeService & operator= (IEnvelopeService &&)=delete

Detailed Description

The UI service: answers ui-hello, ui-catalog and ui-fetch from one ServedBundle, and ui-evaluate through the server's ActionDispatcher, as an envelope service of a RemoteServer (ServerConfig::services).

Every request is authorised (docs/spec/ui/service.md, "Authorisation"):

Kind Gate
ui-hello authorize(session, "ui", "hello")
ui-catalog authorize(session, "ui", "catalog")
ui-fetch of the manifest or a public file the ui-hello gate
ui-fetch of any other file authorize(session, "ui", "fetch"); for a screen, also the catalog's rule
ui-evaluate authorize(session, modelType, actionType): as the action it evaluates

A refusal is err "unauthorized". A request body that is too large, malformed or carries a must-understand key is refused with the parser's reason.

Definition at line 783 of file service.hpp.

Constructor & Destructor Documentation

◆ UiService()

morph::ui::UiService::UiService ( std::shared_ptr< ServedBundle const > bundle,
::morph::model::detail::ActionDispatcher & dispatcher = ::morph::model::detail::defaultDispatcher(),
std::shared_ptr< IFileStore > files = nullptr )
inlineexplicit

Serves bundle, and evaluates through dispatcher.

Parameters
bundleThe bundle; shared, never changed.
dispatcherThe dispatcher ui-evaluate reads the actions from: the server's own. Borrowed: it must outlive the service.
Exceptions
std::invalid_argumentif bundle is null.
Parameters
filesThe file side channel's store; nullptr serves no ui-file.

Definition at line 791 of file service.hpp.

Member Function Documentation

◆ serves()

bool morph::ui::UiService::serves ( std::string_view kind) const
inlinenodiscardoverridevirtual

Whether kind is one of the service's kinds.

Parameters
kindThe envelope kind.
Returns
true for ui-hello, ui-catalog, ui-fetch and ui-evaluate.

Implements morph::backend::IEnvelopeService.

Definition at line 804 of file service.hpp.

◆ handle() [1/2]

std::string morph::ui::UiService::handle ( ::morph::wire::Envelope const & request,
::morph::session::IAuthorizer const & authorizer )
inlinenodiscardoverridevirtual

Answers one request with no connection behind it: a ui-hello offer of events is accepted in the reply, and recorded nowhere.

Parameters
requestThe envelope, its principal verified.
authorizerThe server's authoriser.
Returns
The encoded reply.

Implements morph::backend::IEnvelopeService.

Definition at line 814 of file service.hpp.

◆ handle() [2/2]

std::string morph::ui::UiService::handle ( ::morph::wire::Envelope const & request,
::morph::session::IAuthorizer const & authorizer,
::morph::backend::ConnectionFacts & facts )
inlinenodiscardoverridevirtual

Answers one request; a ui-hello that offers events and is answered ok sets facts.events.

A hello that does not offer them leaves the facts as they are, so a later hello on the same connection, such as a development reload's poll, does not withdraw what the first negotiated.

Parameters
requestThe envelope, its principal verified.
authorizerThe server's authoriser.
factsThe facts of the connection the request arrived on.
Returns
The encoded reply.

Reimplemented from morph::backend::IEnvelopeService.

Definition at line 828 of file service.hpp.


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