Layr8.DidHandle (layr8 v0.2.10)

Copy Markdown View Source

A handle for one additional DID hosted on a Layr8.Client's WebSocket, returned by Layr8.Client.join_did/3.

It is the per-DID counterpart of Layr8.Client.send/3, request/3 and request_result/3: those operate on the DID the client connected with, while these operate on this DID's own channel and stamp from with it.

{:ok, wf} = Layr8.Client.join_did(client, workflow_did, protocols: [proto])
:ok = Layr8.DidHandle.send(wf, %Layr8.Message{type: type, to: [peer], body: %{}})

Modelled on the node-sdk's DidHandle (src/client.ts).

Summary

Functions

The DID this handle hosts.

Leaves this DID's channel. The client and every other DID stay connected.

Sends from this DID and waits for a correlated response. Same contract as Layr8.Client.request/3.

Sends a DIDComm message from this DID. Same contract as Layr8.Client.send/3.

Types

t()

@type t() :: %Layr8.DidHandle{client: pid(), did: String.t()}

Functions

did(did_handle)

@spec did(t()) :: String.t()

The DID this handle hosts.

leave(handle)

@spec leave(t()) :: :ok

Leaves this DID's channel. The client and every other DID stay connected.

request(handle, msg, opts \\ [])

@spec request(t(), Layr8.Message.t() | map(), keyword()) :: {:ok, Layr8.Message.t()}

Sends from this DID and waits for a correlated response. Same contract as Layr8.Client.request/3.

request_result(handle, msg, opts \\ [])

@spec request_result(t(), Layr8.Message.t() | map(), keyword()) ::
  {:ok, Layr8.Message.t()} | {:error, term()}

request/3 without the raises. Same contract as Layr8.Client.request_result/3.

send(handle, msg, opts \\ [])

@spec send(t(), Layr8.Message.t() | map(), keyword()) :: :ok

Sends a DIDComm message from this DID. Same contract as Layr8.Client.send/3.