Coder Social home page Coder Social logo

fbaiodias / js-multistream Goto Github PK

View Code? Open in Web Editor NEW

This project forked from multiformats/js-multistream-select

0.0 1.0 0.0 2.96 MB

implementation of multistream spec https://github.com/ipfs/specs/blob/wire/protocol/network/wire.md#multistream

License: MIT License

JavaScript 100.00%

js-multistream's Introduction

js-multistream

Coverage Status Travis CI Circle CI Dependency Status js-standard-style

JavaScript implementation of multistream.

Installation

npm

> npm i multistream-select

Setup

Node.js

const multistream = require('multistream-select')

Browser: Browserify, Webpack, other bundlers

The code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process.

const multistream = require('multistream-select')

Browser: <script> Tag

Loading this module through a script tag will make the Multistream obj available in the global namespace.

<script src="https://npmcdn.com/multistream-select/dist/index.min.js"></script>
<!-- OR -->
<script src="https://npmcdn.com/multistream-select/dist/index.js"></script>

How does it work

Two modes of operation:

  • silent - broadcast - For one-way style of communications (for when you need a push like MultiStream
  • interactive - select - When you want to suport more than one Protocol in your MultiStream at the same time, where the receiver "selects" the right handler for a specific stream, while the sender "interactively" picks the protocol it wants to use throw req-ack and/or ls for protocol listing

silent - broadcast

The sender doesn't have a confirmation of message reception. Both the dialing endpoint or the caller endpoint can act as the "broadcaster" while the other acts as silent

# Establis a connection through your desired transport
< /multistream-select/0.3.0            # let's speak multistream-select/0.3.0
< /pfs/QmBBQ.../time/0.1.2.            # i'm going to speak time/0.1.2
< 2015-06-07 14:32:11

interactive - select

The caller will send "interactive" messages, expecting for some acknowledgement from the callee, which will "select" the handler for the desired and supported protocol

< /multistream-select/0.3.0  # i speak multistream-select/0.3.0
> /multistream-select/0.3.0  # ok, let's speak multistream-select/0.3.0
> /ipfs-dht/0.2.3            # i want to speak ipfs-dht/0.2.3
< na                         # ipfs-dht/0.2.3 is not available
> /ipfs-dht/0.1.9            # What about ipfs-dht/0.1.9 ?
< /ipfs-dht/0.1.9            # ok let's speak ipfs-dht/0.1.9 -- in a sense acts as an ACK
> <dht-message>
> <dht-message>
> <dht-message>

This mode also packs a ls option, so that the callee can list the protocols it currently supports

Usage/Examples

silent - broadcast

Reference to the examples on the examples folder:

interactive - select

Reference to the examples on the examples folder:

Other impl

js-multistream's People

Contributors

daviddias avatar dignifiedquire avatar richardlitt avatar

Watchers

Francisco avatar

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.