morph
0.1.0
Asynchronous bridge between GUI thread and business models
Toggle main menu visibility
Loading...
Searching...
No Matches
transport.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: Apache-2.0
2
#pragma once
3
4
#include <expected>
5
#include <memory>
6
#include <string>
7
8
#include "../core/backend.hpp"
9
#include "
../core/envelope_transport.hpp
"
10
#include "
../ui/frontend.hpp
"
11
12
/// @file
13
/// @brief The transport a remote client connects with, chosen by the frontend it runs under (spec 4 ยง3).
14
///
15
/// Specified in `docs/spec/client/client.md`.
16
17
namespace
morph::client {
18
19
/// @brief A connection to a server: the bridge's backend and its request verb, which are one object.
20
struct
RemoteTransport
{
21
/// @brief The backend.
22
std::unique_ptr<backend::detail::IBackend>
backend
;
23
/// @brief The same object's `IEnvelopeTransport`; owned by `backend`.
24
backend::IEnvelopeTransport
*
requests
=
nullptr
;
25
};
26
27
/// @brief Connects to @p url with the transport the frontend calls for: a `SocketBackend` on the context's I/O loop
28
/// when it has one (the terminal frontend), a `QtWebSocketBackend` otherwise (Qt Quick).
29
/// @param context The running frontend's context.
30
/// @param url `ws://host:port`.
31
/// @return The transport, connecting; or why there is none: the transport the frontend needs is not built, or the
32
/// URL is refused.
33
[[nodiscard]] std::expected<RemoteTransport, std::string>
makeTransport
(
ui::AppContext
& context,
34
std::string
const
& url);
35
36
namespace
detail {
37
38
/// @brief A `SocketBackend` on @p context's loop; defined only where `morph::net` is built.
39
/// @param context The context; its loop must not be null.
40
/// @param url The server.
41
/// @return The transport, or why the URL is refused.
42
[[nodiscard]] std::expected<RemoteTransport, std::string>
socketTransport
(
ui::AppContext
& context,
43
std::string
const
& url);
44
45
/// @brief A `QtWebSocketBackend`; defined only where `morph::qt` is built.
46
/// @param url The server.
47
/// @return The transport, or why the URL is refused.
48
[[nodiscard]] std::expected<RemoteTransport, std::string>
qtTransport
(std::string
const
& url);
49
50
}
// namespace detail
51
52
}
// namespace morph::client
morph::backend::IEnvelopeTransport
What a wire transport offers beside IBackend: one request, one reply, matched by callId.
Definition
envelope_transport.hpp:21
morph::ui::AppContext
What a frontend lends the source it opens and the screens it mounts.
Definition
frontend.hpp:50
envelope_transport.hpp
IEnvelopeTransport: a transport that sends a request envelope of a kind its backend verbs do not buil...
morph::client::RemoteTransport
A connection to a server: the bridge's backend and its request verb, which are one object.
Definition
transport.hpp:20
morph::client::RemoteTransport::backend
std::unique_ptr< backend::detail::IBackend > backend
The backend.
Definition
transport.hpp:22
morph::client::RemoteTransport::requests
backend::IEnvelopeTransport * requests
The same object's IEnvelopeTransport; owned by backend.
Definition
transport.hpp:24
morph::client::detail::socketTransport
std::expected< RemoteTransport, std::string > socketTransport(ui::AppContext &context, std::string const &url)
A SocketBackend on context's loop; defined only where morph::net is built.
morph::client::makeTransport
std::expected< RemoteTransport, std::string > makeTransport(ui::AppContext &context, std::string const &url)
Connects to url with the transport the frontend calls for: a SocketBackend on the context's I/O loop ...
morph::client::detail::qtTransport
std::expected< RemoteTransport, std::string > qtTransport(std::string const &url)
A QtWebSocketBackend; defined only where morph::qt is built.
frontend.hpp
The frontend seam: main picks a frontend at runtime, and the frontend runs whatever an AppSource open...
morph
client
transport.hpp
Generated by
1.17.0