Stuyk / buoy-client

Browser and node.js client for the buoy message forwarder service

Home Page:https://greymass.github.io/buoy-client/tests.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

buoy-client

Client for buoy message forwarder.

Installation

The @greymass/buoy package is distributed as a module on npm.

yarn add @greymass/buoy
# or
npm install --save @greymass/buoy

Usage

Send a message.

import {send} from '@greymass/buoy'

await send('hello', {service: 'https://cb.anchor.link', channel: 'my-unique-channel-id'})

Receive a message.

import {receive} from '@greymass/buoy'

const message = await receive({service: 'https://cb.anchor.link', channel: 'my-unique-channel-id'})

Listen for a continuous stream of messages.

import {Listener} from '@greymass/buoy'

const listener = new Listener({service: 'https://cb.anchor.link', channel: 'my-unique-channel-id'})

listener.on('message', (message) => {
    console.log('message', message)
})

// make sure to subscribe to the error event or they will be thrown
listener.on('error', (error) => {
    console.warn('listener error', error)
})

Developing

You need Make, node.js and yarn installed.

Clone the repository and run make to checkout all dependencies and build the project. See the Makefile for other useful targets. Before submitting a pull request make sure to run make lint.


Made with ☕️ & ❤️ by Greymass, if you find this useful please consider supporting us.

About

Browser and node.js client for the buoy message forwarder service

https://greymass.github.io/buoy-client/tests.html

License:Other


Languages

Language:TypeScript 72.0%Language:JavaScript 17.8%Language:Makefile 10.1%