View Source ExIpfsPubsub (Elixir IPFS Pubsub Experiment for Elixir v0.0.1)

ExIpfsPubsub is where the Pubsub commands of the IPFS API reside.

Link to this section Summary

Functions

Get next message from the Pubsub Topic in your inbox or wait for one to arrive.

List the topics you are currently subscribed to.

List the peers you are currently connected to.

Publish a message to a topic.

Subscribe to messages on a topic and listen for them.

Link to this section Functions

Link to this function

get_pubsub_topic_message()

View Source
@spec get_pubsub_topic_message() :: any()

Get next message from the Pubsub Topic in your inbox or wait for one to arrive.

This is probably just useful for testing and is just here for the sweetness of it. https://www.youtube.com/watch?v=6jAVHBLvo2c

It's just not good for your health, but OK for your soul.

@spec ls() :: {:error, any()} | {:ok, list()}

List the topics you are currently subscribed to.

https://docs.ipfs.io/reference/http/api/#api-v0-pubsub-ls

@spec peers(binary()) :: {:ok, any()} | ExIpfs.Api.error_response()

List the peers you are currently connected to.

https://docs.ipfs.io/reference/http/api/#api-v0-pubsub-peers

parameters

Parameters

topic - The topic to list peers for.

@spec pub(binary(), binary()) :: {:ok, any()} | ExIpfs.Api.error_response()

Publish a message to a topic.

https://docs.ipfs.io/reference/http/api/#api-v0-pubsub-pub

parameters

Parameters

  `topic` - The topic to publish to.
  `data` - The data to publish.

usage

Usage

ExIpfsPubsub.sub("mymessage", "mytopic")
Link to this function

sub(topic, pid \\ self())

View Source
@spec sub(binary(), pid()) :: {:ok, pid()} | ExIpfs.Api.error_response()

Subscribe to messages on a topic and listen for them.

https://docs.ipfs.io/reference/http/api/#api-v0-pubsub-sub

Messages are sent to the process as a tuple of {:ex_ipfs_pubsub_topic_message, message}. This should make it easy to pattern match on the messages in a receive do loop.

parameters

Parameters

topic - The topic to subscribe to. pid - The process to send the messages to.

usage

Usage

ExIpfsPubsub.sub(self(), "mytopic")

Returns {:ok, pid} where pid is the pid of the GenServer that is listening for messages. Messages will be sent to the provided as a parameter to the function.