chatmesh-db

2.0.2 • Public • Published

chatmesh-db

p2p db functions for chat

Usage

npm install chatmesh-db

API

Table of Contents

Mesh

Create a new Chatmesh. This is the object handling all local nickname -> mesh interactions for a single user.

Parameters

  • storage (string | function) A hyperdb compatible storage function, or a string representing the local data path.
  • href string The dat link
  • opts Object Options include: username

onconnection

When a connection is made. Auto-authorizes new peers to write to the local database. Maintains the local view of visible users.

Parameters

  • peer Object The discovery-swarm peer emitted from the 'connection' or 'disconnection' event

joinChannel

Join a channel.

Parameters

  • channel String The channel to join.

leaveChannel

Leave a channel.

Parameters

  • channel String The channel to leave.

createReadStream

Create a readable stream for the mesh.

Parameters

  • channel String The channel you want to read from.

message

Create a message.

Parameters

  • channel String The channel to create the message.
  • message String The message to write.
  • opts Object Options: date, username
  • done function When message has been successfully added.

replicate

Replication stream for the mesh. Shares the username with the other peers it is connecting with.

Dependencies (5)

Dev Dependencies (4)

Package Sidebar

Install

npm i chatmesh-db

Weekly Downloads

2

Version

2.0.2

License

AGPL-3.0

Unpacked Size

44.3 kB

Total Files

7

Last publish

Collaborators

  • karissa