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

Fetches the screens from a server (--server), over the transport the frontend calls for. More...

#include <source.hpp>

Inheritance diagram for morph::client::RemoteSource:
morph::client::Source morph::ui::AppSource

Public Member Functions

 RemoteSource (std::string url, std::chrono::milliseconds timeout=std::chrono::seconds{10})
 A source for url.
Public Member Functions inherited from morph::client::Source
ui::Dispatcher & dispatcher ()
 Where the screens' model calls go.
ui::Catalog catalog () const
 The catalog facts the screens load with.
std::vector< std::string > screens () const
 The screens the principal may open, in catalog order: each catalog entry that is available or public and whose document the bundle holds.
bool isPublic (std::string_view screenId) const
 Whether the catalog marks screenId public: a screen served before sign-in, such as a login screen.
void open (ui::AppContext &context, std::function< void(std::expected< ui::Bundle, ui::ConnectError >)> ready) final
 Opens the source: the transport, the bridge and the bundle, verified.
void switchBackend (ui::Backend backend, std::function< void(std::expected< void, std::string >)> done) final
 Refused: a switch between backends is the hosting layer's (spec 6 §9).
void close () final
 Drops a ready not yet delivered and releases the bridge, the transport and the bundle.
void signIn (std::string principal, std::string token, std::function< void(bool)> done)
 Installs a sign-in (spec 6 §5): a session built from the current one with principal and token replaced, carried by every later model call and UI-service request, then the catalog reloaded for it.
void signOut (std::function< void(bool)> done)
 Ends the session: back to the principal before any sign-in, with no token, and the catalog reloaded for it.
std::function< std::shared_ptr< ui::Document const >(std::string_view)> documents (std::function< void(ui::Refusal const &)> onRefused={})
 The lookup a DocumentScreenHost takes (DocumentScreenHostOptions::documents), over the loaded bundle: each screen the source lists, loaded against the current catalog facts the first time it is asked for after a load, so a shell of an application's own mounts with the same source.
ui::Bundle const * bundle () const noexcept
 The bundle the catalog currently lists.
ui::CatalogReply const * catalogReply () const noexcept
 The catalog for the current principal: its entries, what the principal may run, and the facts.
ui::SchemasByModel const & schemasByModel () const noexcept
 The schemas document of every model the catalog names, by model type, or why it did not arrive: what the explorer lists each model's actions from.
std::string const & principal () const noexcept
 The principal the source's session carries now.
std::optional< ui::FileTransfer > files () const
 The file side channel (files/1) over the source's exchange, carrying its session: what a screen's upload and download move bytes through.
void poll (std::function< void(std::vector< std::string > changed)> changed)
 One step of development reload (spec 5 §12): sends ui-hello, and when the manifest digest changed, fetches the changed bundle and the catalog for it. Nothing is sent while a poll is still in flight.
void onConnected (std::function< void()> const &listener) final
 Adds a listener called on the owner after each successful connect, the first included. On a reconnect the source first sends ui-hello again, so the new connection negotiates events, then calls the listeners.
void onEvent (std::function< void(wire::EventBody const &)> listener)
 Adds a listener for the events the server sends: what a shell hands to Session::deliverEvent.
ui::Watcher watcher ()
 What the session's SessionOptions::watcher sends the cache's watch changes through: watcherOver the source's exchange, stamping the session current at each send. Empty for a source whose transport carries no server events, such as an in-process one.
virtual std::string signedOutPrincipal () const
 The principal before any sign-in, which signOut returns to.
Public Member Functions inherited from morph::ui::AppSource
 AppSource (AppSource const &)=delete
AppSource & operator= (AppSource const &)=delete
 AppSource (AppSource &&)=delete
AppSource & operator= (AppSource &&)=delete
virtual void open (AppContext &context, std::function< void(std::expected< Bundle, ConnectError >)> ready)=0
 Connects (or, local, sets up the models), signs the user in natively if the application needs it, and delivers the bundle.

Protected Member Functions

std::expected< Transport, ui::ConnectError > connect (ui::AppContext &context) override
 Makes the transport on context.
std::chrono::milliseconds openTimeout () const override
 How long open waits for the bundle before it reports the source unreachable; zero waits forever.
Protected Member Functions inherited from morph::client::Source
virtual void disconnect ()
 Releases what connect made beside the backend; called by close, after the bridge is gone.
virtual void fetchSchemas (std::string const &modelType, std::function< void(std::expected< std::string, std::string >)> done)
 Fetches the {actionType: schema} document of one model type, which a form, collection or wizard node is built from. The default sends a schemas envelope over the source's exchange.
session::Context & requestSession () noexcept
 The session every request carries, for a source to fill before open sends anything.

Detailed Description

Fetches the screens from a server (--server), over the transport the frontend calls for.

Definition at line 267 of file source.hpp.

Constructor & Destructor Documentation

◆ RemoteSource()

morph::client::RemoteSource::RemoteSource ( std::string url,
std::chrono::milliseconds timeout = std::chrono::seconds{10} )
explicit

A source for url.

Parameters
urlws://host:port.
timeoutHow long to wait for the bundle before reporting the server unreachable.

Member Function Documentation

◆ connect()

std::expected< Transport, ui::ConnectError > morph::client::RemoteSource::connect ( ui::AppContext & context)
nodiscardoverrideprotectedvirtual

Makes the transport on context.

Parameters
contextThe running frontend's context.
Returns
The transport, or why there is none.

Implements morph::client::Source.

◆ openTimeout()

std::chrono::milliseconds morph::client::RemoteSource::openTimeout ( ) const
inlinenodiscardoverrideprotectedvirtual

How long open waits for the bundle before it reports the source unreachable; zero waits forever.

Returns
The bound.

Reimplemented from morph::client::Source.

Definition at line 276 of file source.hpp.


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