Code Monkey home page Code Monkey logo

orbit-db-pubsub's Introduction

orbit-db-pubsub

Gitter Matrix Discord npm version

Message propagation module for orbit-db

Default message propagation service for orbit-db. Uses IPFS pubsub.

Install

This project uses npm and nodejs.

npm install orbit-db-pubsub

Usage

API

subscribe(topic, onMessageHandler, onNewPeerHandler)

Listen for new messages in topic

onMessageHandler gets called when a message is received with signature (topic, data)

onNewPeerHandler gets called when a new peer joins with signature (topic, peer)

Returns a promise.

unsubscribe(topic)

Stop listening for new messages in topic

Returns a promise.

disconnect ()

Stop listening for new messages in all topics

Returns a promise.

publish(topic, data)

Publish data to a topic

Contributing

If you think this could be better, please open an issue!

Please note that all interactions in @orbitdb fall under our Code of Conduct.

License

MIT Šī¸ 2016-2018 Protocol Labs Inc., Haja Networks Oy

orbit-db-pubsub's People

Contributors

adam-palazzo avatar aphelionz avatar haadcode avatar haydenyoung avatar mistakia avatar msterle avatar richardlitt avatar shamb0t avatar threshold862543 avatar vaultec81 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orbit-db-pubsub's Issues

Reduce repository number

This appears to be a repository
with 8 meta, config or repo files
for 1 actual source file.

Is this necessary?

The only repository using this source file
I found was orbit-db, so I would propose
putting the file into the repo and making
the publishing dance easier.

Add unit tests

We currently do all testing in the main OrbitDB repo and while this module gets fairly well (integration-) tested as part of it, we should really have unit tests in this repo.

How use orbitdb-db-pubsub ?

I can't find any example to use this module.
I tried this code but I got : TypeError: orbit.subscribe is not a function

var  orbit = require('orbit-db-pubsub');
orbit.subscribe("top", r => console.log(r))

TypeError: this._ipfs._libp2pNode.dialProtocol is not a function

/home/ubuntu/persistent-peers/base-peer/node_modules/orbit-db-pubsub/node_modules/ipfs-pubsub-room/src/connection.js:50
      this._ipfs._libp2pNode.dialProtocol(peerAddresses[0], PROTOCOL, (err, conn) => {
                             ^

TypeError: this._ipfs._libp2pNode.dialProtocol is not a function

My code in its entirety is below

class PersistentPeer {
  constructor(ipfsPath) {
    var ipfsConfig = {
      config: {
        "Addresses": {
          "Swarm": [
            '/dns4/redacted.com/tcp/9091/wss/p2p-websocket-star'
          ]
        }
      },
      EXPERIMENTAL: {
        pubsub: true
      }
    };
    
    if(ipfsPath) {
      ipfsConfig.repo = ipfsPath + "/_ipfs";
    }
    
    this.ipfs = new IPFS(ipfsConfig);
    this.ipfs.on('error', (e) => console.error(e));
    this.ipfs.once('ready', () => this._setupOrbitDB.apply(this));
  }

  async _setupOrbitDB() {
    this.orbitdb = new OrbitDB(this.ipfs);
    this.postDBCreation();
  }
  
  async postDBCreation() {
    
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.