View Source MyspaceIPFS.PubSub (Myspace IPFS v0.2.0-alpha.1)
MyspaceIPFS.PubSub is where the pubsub commands of the IPFS API reside.
Link to this section Summary
Functions
Get next message from the pubsub channel 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
@spec get_pubsub_channel_message() :: any()
Get next message from the pubsub channel 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() :: {:ok, MyspaceIPFS.strings()} | MyspaceIPFS.Api.error_response()
List the topics you are currently subscribed to.
@spec peers(binary()) :: {:ok, any()} | MyspaceIPFS.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()} | MyspaceIPFS.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
MyspaceIPFS.PubSub.sub("mymessage", "mytopic")
@spec sub(pid(), binary()) :: any() | MyspaceIPFS.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 {:myspace_ipfs_pubsub_channel_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.