8000 How to do PubSub · Issue #11 · vyzo/gerbil-libp2p · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
How to do PubSub #11
Open
Open
@janus

Description

@janus

I would like to use PubSub. But there is no example out there.

(def (start-pubsub-node host-addresses)
  (let* ((c (open-libp2p-client host-addresses: host-addresses options: ["-pubsub" "-pubsubRouter" "gossipsub"] wait: 20))
         (self (libp2p-identify c)))
    (pubsub-subscribe c "Never")
    (for (p (peer-info->string* self))
      (displayln "I am " p))
    (displayln "Listening for incoming connections")))

(def (start-pubsub-node host-addresses)
  (let* ((c (open-libp2p-client host-addresses: host-addresses options: ["-pubsub" "-pubsubRouter" "gossipsub"] wait: 20))
         (self (libp2p-identify c)))
    (pubsub-subscribe c "Never")
    (for (p (peer-info->string* self))
      (displayln "I am " p))
   (libp2p-connect c peer)
    (displayln "Listening for incoming connections")))

I also noticed that there is a channel out there.

(pubsub-subscribe c topic)
  c      := client
  topic: = string
=> (values sub cancel)
  sub    := channel; message channel
  cancel := lambda (); thunk to cancel the subscription
  message := (vector ID data seqno topics signature key)

How can I use it?

39AA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0