Next: , Up: Services and Communication: Server and Client   [Contents]


B.8.1 STServer: Publishing a Service

STServer exposes STInput/STOutput arrays over D-Bus TCP and listens to each object’s notify to forward updates.

Access may be anonymous (default) or protected with a shared authentication token. With a token set, clients must Authenticate before I/O methods; the server compares a SHA-256 digest and drops mismatches. Core: gsettings org.starter.core auth-token or --auth-token. Clients: st_client_set_auth_token before start.

Function: STServer * st_server_new (const gchar *name, const STVersion *version, GPtrArray *inputs, GPtrArray *outputs)

Creates a server that will publish the given I/O arrays. Arrays are shared (not copied): mutations in your objects are visible to the server.

name

Service name (e.g. ST:MyService).

version

Pointer to version triple (copied).

inputs

GPtrArray of STInput * (element destroy typically g_object_unref).

outputs

GPtrArray of STOutput *.

Returns: New STServer.

Function: gboolean st_server_start (STServer *self, guint16 port, GError **error)

Binds the D-Bus TCP listener and starts serving.

self

Server.

port

TCP port; 0 requests an ephemeral port (then use st_server_get_port).

error

Filled on bind/listen failure.

Returns: TRUE on success, FALSE on failure.

Function: guint16 st_server_get_port (const STServer *self)

Reads the bound port (meaningful after a successful start).

self

Server.

Returns: Port number, or 0 if not running.

Function: gboolean st_server_get_running (const STServer *self)

Reports whether the listener is active.

self

Server.

Returns: TRUE if running.

Function: void st_server_stop (STServer *self)

Stops the listener and drops peers.

self

Server.

Returns: Nothing.

Function: gboolean st_server_swap (STServer *self, guint16 port, GError **error)

Stops and rebinds on a new port (or ephemeral if 0).

self

Server.

port

New port, or 0 for ephemeral.

error

Filled on failure.

Returns: TRUE on success.

Function: void st_server_set_bind_address (STServer *self, const gchar *addr)

Sets the bind address string used on the next start (e.g. 0.0.0.0 or 127.0.0.1).

self

Server.

addr

Address string; copied.

Returns: Nothing.

Function: gchar * st_server_get_bind_address (const STServer *self)

Reads the configured bind address.

self

Server.

Returns: Newly allocated address string (transfer full), or NULL.

Function: void st_server_set_listen_context (STServer *self, GMainContext *ctx)

Sets the main context for the D-Bus server listen loop.

self

Server.

ctx

Context, or NULL for default.

Returns: Nothing.

Function: GMainContext * st_server_get_listen_context (const STServer *self)

Reads the listen context.

self

Server.

Returns: Borrowed GMainContext.

Function: void st_server_set_auth_token (STServer *self, const gchar *token)

Configures the shared peer auth secret. Empty or NULL means anonymous access.

self

Server.

token

Shared secret, or NULL/empty for anonymous.

Returns: Nothing.

Function: gchar * st_server_get_auth_token (const STServer *self)

Reads the configured token.

self

Server.

Returns: Newly allocated token (transfer full), or NULL.


Next: STClient: Consuming a Service, Up: Services and Communication: Server and Client   [Contents]