Introduction
Peerchat is a CLI app that allows to chat via DStack PubSub API without any configuration
Demo
Try it out!
Install
$ npm i -g peerchat
$ yarn global add peerchat
Usage
$ # peerchat [channel] [nickname]
$ peerchat dstack steve
How it works?
DStack provides PubSub API
Peerchat uses it to communicate between users
Code Examples
Listening to messages
await stack.pubsub.subscribe(room, (event) => {
const username = event.data.nickname
? `${event.data.nickname} (${event.from.slice(-5)})`
: event.from.slice(-5);
messageList.addItem(`${username}: ${event.data.message}`);
messageList.scrollTo(100);
screen.render();
});
Sending message
await pubsub.publish(room, { nickname, message });
Get started with DStack
See Tutorial to get started using DStack in your app