Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PsTopicSubscription ¶
type PsTopicSubscription struct { Topic *libp2pPS.Topic Sub *libp2pPS.Subscription // contains filtered or unexported fields }
PsTopicSubscription is returned when the host joins/subs to a topic using the created JoinSubscribeTopic method. With its values, the host can deal with all the available attributes and methods for the given *libp2p.Topic and *libp2p.Subscribe.
func (*PsTopicSubscription) Close ¶
func (ts *PsTopicSubscription) Close(ctx context.Context) error
Close closes both subscription and topic for the given values assigned to ts *PsTopicSubscription
func (*PsTopicSubscription) ListenForMessages ¶
func (ts *PsTopicSubscription) ListenForMessages(ctx context.Context, msgCh chan *libp2pPS.Message)
ListenForMessages receives a channel of type *libp2pPS.Message and it sends all the messages received for a given topic to this channel. Ignoring the messages send by the host
func (*PsTopicSubscription) Publish ¶
func (ts *PsTopicSubscription) Publish(msg any) error
Publish publishes the given message to the objected topic
func (*PsTopicSubscription) Unsubscribe ¶
func (ts *PsTopicSubscription) Unsubscribe()
Unsubscribe unsubscribes from the topic subscription.
type PubSub ¶
type PubSub struct { *libp2pPS.PubSub // Keeps track of subscribed topics returning the PsTopicSubscription object // with the related topic methods. It's useful when we try to publish in a given // topic from different places that do not have access to the *libp2p.topic/sub // object SubscribedTopics map[string]*PsTopicSubscription // contains filtered or unexported fields }
PubSub is basically a wrapper around *libp2p.PubSub original struct which has one additional method for joining and subscribing to a given topic
func NewGossipPubSub ¶
NewGossipPubSub creates a new GossipSub instance with the given host or returns an existing one if it has been previously created. Note: it must be called before connected to peers, otherwise, peers might be invisible within the entered topics
func (*PubSub) JoinSubscribeTopic ¶
func (ps *PubSub) JoinSubscribeTopic(ctx context.Context, topicName string, debug bool) (*PsTopicSubscription, error)
JoinSubscribeTopic joins the given topic and subscribes to the topic.