Skip to content

Editor → Protocol → protocol_transport.h

protocol_transport

Syntax

class CONJURE_API protocol_transport

Derived Classes

Classes that use this as a base

Constructors

AccessSignatureDescription
publicprotocol_transport();

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
publicvirtual ~protocol_transport();

Variables

AccessNameTypeDefaultDescription
privatemAllocatorclient_id_allocator{}
privatemNextLocalIdu321

Functions

Public

client_count

[[nodiscard]] virtual usize client_count() const noexcept = 0;

Connected clients.

disconnect

virtual void disconnect(
    u32 clientId) = 0;

Closes a client; the next poll() reports it closed.

flush

virtual void flush() = 0;

Writes queued bytes without blocking.

kind

[[nodiscard]] virtual transport_kind kind() const noexcept = 0;

pending_bytes

[[nodiscard]] virtual usize pending_bytes(
    u32 clientId) const noexcept = 0;

Bytes queued for a client and not yet written (the backlog policy reads it).

poll

virtual void poll(
    std::vector<u32> &outOpened,
    std::vector<inbound_line> &outLines,
    std::vector<u32> &outClosed) = 0;

Collects what happened since the last call: new clients (ids allocated through the allocator), complete lines and closed clients, in that order. Never blocks.

send

virtual void send(
    u32 clientId,
    std::string_view line) = 0;

Queues a line (a newline is appended) for a client. Unknown ids are ignored.

set_client_id_allocator

void set_client_id_allocator(
    client_id_allocator allocator);

The server installs its id allocator before start(). Without one ids count from 1.

start

[[nodiscard]] virtual core::result<void> start() = 0;

Opens the transport (binds the socket, starts the reader thread).

stop

virtual void stop() = 0;

Closes every client and releases the resources. Idempotent.

Protected

allocate_client_id

[[nodiscard]] u32 allocate_client_id();

The next client id from the allocator (or a local counter).