Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dapplion/swarmcitychat
Temporal chat solution while a p2p / decentralized solution is being developed
https://github.com/dapplion/swarmcitychat
Last synced: about 19 hours ago
JSON representation
Temporal chat solution while a p2p / decentralized solution is being developed
- Host: GitHub
- URL: https://github.com/dapplion/swarmcitychat
- Owner: dapplion
- Created: 2019-02-20T19:51:51.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-24T16:49:28.000Z (almost 6 years ago)
- Last Synced: 2024-12-28T06:48:02.691Z (10 days ago)
- Language: JavaScript
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwarmCityChat
Temporal chat solution while a p2p / decentralized solution is being developed
## Usage
Connect using the socket.io client to the root domain without any location, with the following options
```js
const url "http(s)://yourdomain.io"
const options = {
transports: ["websocket"],
};
const socket = require("socket.io-client")(url, options);
```### Methods
- subscribe:
```js
const data = { hashtagAddress, itemHash, accessKeys, metadata };
sender.emit("subscribe", data, acknowledgement);
```- message:
```js
const data = { hashtagAddress, itemHash, message };
sender.emit("message", data, acknowledgement);
```- chatChanged:
```js
sender.on("chatChanged", chatObject => {
// display chat metadata
// Loop accessKeys and find yours
// decrypt messages with our accessKey
});
``````js
chatObject = {
accessKeys: ["secret-access-key-1", "secret-access-key-2"],
messages: ["secret-message-1", "secret-message-2"],
metadata: { description: "item-1" }
};
```### Acknowledgement
Callback to know if the action triggered by the emit was successful
```js
function acknowledgement(res) {
if (res.error) {
// display error
} else {
// do something with res.data if necessary
}
}
```- on success:
```js
const res = {
error: null,
data: res || {}
};
```- on error:
```js
const res = {
error: e.stack
};
```