class

Arcana::Client

Inherits Reference < Object

WebSocket client for connecting to an Arcana bus server.

Connects to ws://host:port/bus, joins with an address, then becomes a full bus participant — send, publish, subscribe, and receive pushed envelopes in real time via the on_message handler.

client = Arcana::Client.new( url: "ws://localhost:19118/bus", address: "shoppe:storefront", # services: owner:capability name: "Shoppe", description: "Print-on-demand storefront generator", tags: ["storefront", "print-on-demand"], )

client.on_message do |envelope| # handle the envelope; reply via client.send(envelope.reply(...)) end

client.connect # blocks: runs the receive loop

For pure consumers (code that uses services but doesn't expose any), pass listed: false so the directory doesn't show an entry that's never meant to be addressed:

client = Arcana::Client.new( url: "ws://localhost:19118/bus", address: "wow-io", # plain agent name listed: false, # mailbox only, no directory entry )

Constructors

new(url : String, address : String, name : String | Nil = nil, description : String | Nil = nil, kind : Directory::Kind | Nil = nil, guide : String | Nil = nil, schema : JSON::Any | Nil = nil, tags : Array(String) = [] of String, listed : Bool = true)
Source

Instance methods

address

Identity readers (Toolset reads these when constructed over Client).

Source
close

Close the connection.

Source
connect

Open the WebSocket, send the join frame, and run the receive loop. Blocks until the connection closes. Run in a fiber (spawn { client.connect }) if you need to do other work concurrently.

Source
connected?

Is the client currently connected?

Source
description
Source
guide
Source
kind
Source
name
Source
on_message

Register a handler for incoming envelopes. Set before calling connect.

Source
publish(topic : String, envelope : Envelope)

Publish an envelope to all subscribers of topic.

Source
request(envelope : Envelope, timeout : Time::Span = 30.seconds) : Envelope | Nil

Send an envelope and block until a reply with the same correlation_id arrives or the timeout expires. Returns nil on timeout.

Source
send(envelope : Envelope)

Send an envelope to its to address.

Source
service?

Is this client registered as a service (vs. an agent)? If kind was set explicitly at construction, use that; otherwise fall back to the address-syntax guess.

Source
subscribe(topic : String)

Subscribe this address to a topic.

Source
unsubscribe(topic : String)

Unsubscribe this address from a topic.

Source