From 4f46d508dcc62d7ea1ab56d21cef2b88759b703f Mon Sep 17 00:00:00 2001 From: Peter Ott Date: Wed, 4 Dec 2024 14:40:26 +0100 Subject: [PATCH 1/2] Changes version to 0.2.0 - all unit tests exist --- package.json | 2 +- src/core.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d4e8852..af66fd2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solarpunkltd/swarm-decentralized-chat", - "version": "0.1.16", + "version": "0.2.0", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": { diff --git a/src/core.ts b/src/core.ts index b8aa563..764790a 100644 --- a/src/core.ts +++ b/src/core.ts @@ -124,7 +124,7 @@ export class SwarmChat { this.messagesQueue = new AsyncQueue({ waitable: true, max: 4 }, this.handleError.bind(this), this.logger); this.reqTimeAvg = new RunningAverage(1000, this.logger); - this.logger.info(`SwarmChat created, version: v0.1.16 or above`); + this.logger.info(`SwarmChat created, version: v0.2.0 or above`); } /** With getChatActions, it's possible to listen to events on front end or anywhere outside the library. From 8dcf0b36d3af9e259dd9284579d932695fea6ab4 Mon Sep 17 00:00:00 2001 From: Peter Ott Date: Thu, 5 Dec 2024 15:25:15 +0100 Subject: [PATCH 2/2] Adds Possible settings --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ jest | 0 2 files changed, 63 insertions(+) delete mode 100644 jest diff --git a/README.md b/README.md index 847f798..73dcb9b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,68 @@ # Swarm Decentralized Chat +## Overview + A decentralized group chat library that uses [Swarm feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds/) for user list handling, and message sending as well. Currently work-in-progress, don't use it in production! + +## Installation and Usage + +x) Install Bee +You need to have access to a Bee node, with a valid stamp. Follow [these instructions](), to install Bee. +If you have access to a Bee node, next step is to add the library to your project + +x) Install swarm-cli +`npm install -g @ethersphere/swarm-cli + +x) Buy Stamp +To buy stamp for ~1 day, you should run this command: +`swarm-cli stamp buy --depth 22 --amount 480m + +x) Add the library to you project +`npm install --save @solarpunkltd/swarm-decentralized-chat + +x) Set up swarm-decentralized-chat, to receive messages + + + + + +To use SwarmChat in your project, you need to create a SwarmChat instance. To use default settings, you can simply do this like this: +``` +chat = new SwarmChat(); +``` +Bee url will be `http://localhost:1633`. + +If you want to use different node, you can do that the following way: +``` +chat = new SwarmChat({ + url: "https://myurl.com:1633" +}); +``` + +### Possible settings for `SwarmChat`: + - `url`: Bee url with port (e.g. "http://myurl.com:1633") + - `gateway`: Overlay address of the gateway. If exists, SwarmChat will run in gateway mode + - `gsocResourceId`: Non-gateway nodes need to provide this, when in gateway mode. It was created on the gateway. + - `prettier`: Enable prettier lib, which adds colorizing capabilities to logs (browsers do not support this) + - `usersFeedTimeout` Can adjust UsersFeedCommit write timeout, but higher values might cause SocketHangUp in Bee. This is provided in ms + - `removeInactiveInterval` This is how often removeIdleUsers will run, specified in ms + - `idleTime`: Can adjust idle time, after that, usser is inactive (messages not polled). Default is 10 minutes (10000). Specified in ms. + - `userLimit`: Maximum active users. This is stronger than idleTime, either this many users will be polled for new messages, or idleTime. Default value is 20. + - `messageCheckInterval`: Start value for messageCheckInterval. If not specified, the default value is 3x the value of `messageFetchMin` (which is 300 ms by default) + - `userUpdateInterval`: How often getNewUsers will run (ms) + - `maxTimeout`: This is the max timeout for readMessage. Increases performance, but if this is lower than a normal readMessage time, you won't be able to read messages! + - `maxParallelIncreaseLimit`: If average request time is below this, max parallel request count of the messageQueue is increased. More messages will be read in parallel. + - `maxParallelDecreaseLimit`: If average request time is above this, max parallel request count of the messageQueue is decreased. Less messages will be read in parallel. + - `fetchIntervalIncreaseLimit`: If average request time is above this, message fetch interval is increased (lower frequency, ms) + - `fetchIntervalDecreaseLimit`: If average request time is below this, message fetch interval is decreased (higher frequency, ms) + - `messageFetchMin`: The `messageCheckInterval` is dynamically adjusted, this is the lowest value possible (ms) + - `messageFetchMax`: The `messageCheckInterval` is dynamically adjusted, this is the highest value possible (ms) + - `fStep`: When fetch interval is changed, it is changed by this value + - `logLevel`: Log level can be one of the following values: `fatal` | `error` | `warn` | `info` | `debug` | `trace` | `silent` + + +## Contributing + +.. \ No newline at end of file diff --git a/jest b/jest deleted file mode 100644 index e69de29..0000000