mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-18 15:26:50 +00:00
Merge pull request #190 from status-im/topic-guidelines
This commit is contained in:
commit
0e4a891576
@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
- Enable access to `WakuMessage.timestamp`.
|
- Enable access to `WakuMessage.timestamp`.
|
||||||
- Examples (web chat): Use `WakuMessage.timestamp` as unique key for list items.
|
- Examples (web chat): Use `WakuMessage.timestamp` as unique key for list items.
|
||||||
|
- Doc: Link to new [topic guidelines](https://rfc.vac.dev/spec/23/) in README.
|
||||||
|
- Doc: Link to [Waku v2 Toy Chat specs](https://rfc.vac.dev/spec/22/) in README.
|
||||||
|
|
||||||
## [0.5.0] - 2021-05-21
|
## [0.5.0] - 2021-05-21
|
||||||
|
|
||||||
|
14
README.md
14
README.md
@ -49,18 +49,17 @@ await Promise.all(
|
|||||||
|
|
||||||
The `contentTopic` is a metadata `string` that allows categorization of messages on the waku network.
|
The `contentTopic` is a metadata `string` that allows categorization of messages on the waku network.
|
||||||
Depending on your use case, you can either create one (or several) new `contentTopic`(s) or look at the [RFCs](https://rfc.vac.dev/) and use an existing `contentTopic`.
|
Depending on your use case, you can either create one (or several) new `contentTopic`(s) or look at the [RFCs](https://rfc.vac.dev/) and use an existing `contentTopic`.
|
||||||
See the [Waku v2 Message spec](https://rfc.vac.dev/spec/14/) for more details.
|
See the [Waku v2 Topic Usage Recommendations](https://rfc.vac.dev/spec/23/) for more details.
|
||||||
|
|
||||||
For example, if you were to use a new `contentTopic` such as `"my-cool-app"`,
|
For example, if you were to use a new `contentTopic` such as `/my-cool-app/1/my-use-case/proto`,
|
||||||
here is how to listen to new messages received via [Waku v2 Relay](https://rfc.vac.dev/spec/11/):
|
here is how to listen to new messages received via [Waku v2 Relay](https://rfc.vac.dev/spec/11/):
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
waku.relay.addObserver((msg) => {
|
waku.relay.addObserver((msg) => {
|
||||||
console.log("Message received:", msg.payloadAsUtf8)
|
console.log("Message received:", msg.payloadAsUtf8)
|
||||||
}, ["my-cool-app"]);
|
}, ["/my-cool-app/1/my-use-case/proto"]);
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the guidelines regarding content topic format are yet to be defined, see [vacp2p/rfc#364](https://github.com/vacp2p/rfc/issues/364).
|
|
||||||
The examples chat apps currently use content topic `"/waku/2/huilong/proto"`.
|
The examples chat apps currently use content topic `"/waku/2/huilong/proto"`.
|
||||||
|
|
||||||
Send a message on the waku relay network:
|
Send a message on the waku relay network:
|
||||||
@ -68,7 +67,7 @@ Send a message on the waku relay network:
|
|||||||
```javascript
|
```javascript
|
||||||
import { WakuMessage } from 'js-waku';
|
import { WakuMessage } from 'js-waku';
|
||||||
|
|
||||||
const msg = WakuMessage.fromUtf8String("Here is a message!", "my-cool-app")
|
const msg = WakuMessage.fromUtf8String("Here is a message!", "/my-cool-app/1/my-use-case/proto")
|
||||||
await waku.relay.send(msg);
|
await waku.relay.send(msg);
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -146,7 +145,8 @@ or [\#waku-support on Status Discord](https://discord.gg/VChNsDdj).
|
|||||||
## Web Chat App (ReactJS)
|
## Web Chat App (ReactJS)
|
||||||
|
|
||||||
A ReactJS chat app is provided as a showcase of the library used in the browser.
|
A ReactJS chat app is provided as a showcase of the library used in the browser.
|
||||||
A deployed version is available at https://status-im.github.io/js-waku/
|
It implements [Waku v2 Toy Chat](https://rfc.vac.dev/spec/22/) protocol.
|
||||||
|
A deployed version is available at https://status-im.github.io/js-waku/.
|
||||||
|
|
||||||
Find the code in the [examples folder](https://github.com/status-im/js-waku/tree/main/examples/web-chat).
|
Find the code in the [examples folder](https://github.com/status-im/js-waku/tree/main/examples/web-chat).
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ Use `/help` to see the available commands.
|
|||||||
## CLI Chat App (NodeJS)
|
## CLI Chat App (NodeJS)
|
||||||
|
|
||||||
A node chat app is provided as a working example of the library.
|
A node chat app is provided as a working example of the library.
|
||||||
It is interoperable with the [nim-waku chat app example](https://github.com/status-im/nim-waku/blob/master/examples/v2/chat2.nim).
|
It implements [Waku v2 Toy Chat](https://rfc.vac.dev/spec/22/) protocol.
|
||||||
|
|
||||||
Find the code in the [examples folder](https://github.com/status-im/js-waku/tree/main/examples/cli-chat).
|
Find the code in the [examples folder](https://github.com/status-im/js-waku/tree/main/examples/cli-chat).
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user