View Source MyspacePubsub (MyspacePubsub v0.0.2)
MyspacePubsub is where the Pubsub commands of the IPFS API reside.
Summary
Functions
Checks if a topic exists in the list of topics that the node is subscribed to.
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.
Lists the topics that the node is subscribed to.
Lists the topics that the node is subscribed to.
Lists the peers that are participating in the given topic.
Lists the peers that are participating in the given topic.
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_pubsub_topic_message, message}
.
This should make it easy to pattern match on the messages in a receive do loop.
Functions
Checks if a topic exists in the list of topics that the node is subscribed to.
Parameters
topic
- The topic to check for.
@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.
Lists the topics that the node is subscribed to.
@spec ls!() :: [binary()]
Lists the topics that the node is subscribed to.
Lists the peers that are participating in the given topic.
Parameters
topic
- The topic to list peers for.
Returns
A tuple {:ok, peers}
on success, where peers is a list of peer identifiers.
Returns {:error, reason}
on failure.
Lists the peers that are participating in the given topic.
Parameters
topic
- The topic to list peers for.
Returns
A list of peer identifiers.
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_pubsub_topic_message, message}
.
This should make it easy to pattern match on the messages in a receive do loop.
## Parameters
`topic` - The topic to subscribe to.
`pid` - The process to send the messages to.
## Usage MyspacePubsub.sub("mytopic") MyspacePubsub.sub("mytopic", self()) # Same as above MyspacePubsub.sub("mytopic", pid) # Send messages to a specific process
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.