p2p db functions for chat
npm install chatmesh-db
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.hrefstring The dat linkoptsObject Options include: username
When a connection is made. Auto-authorizes new peers to write to the local database. Maintains the local view of visible users.
Parameters
peerObject The discovery-swarm peer emitted from the 'connection' or 'disconnection' event
Join a channel.
Parameters
channelString The channel to join.
Leave a channel.
Parameters
channelString The channel to leave.
Create a readable stream for the mesh.
Parameters
channelString The channel you want to read from.
Create a message.
Parameters
channelString The channel to create the message.messageString The message to write.optsObject Options: date, usernamedonefunction When message has been successfully added.
Replication stream for the mesh. Shares the username with the other peers it is connecting with.