mirror of
https://github.com/logos-messaging/docs.waku.org.git
synced 2026-01-10 08:43:09 +00:00
send returns message id
This commit is contained in:
parent
d8886e02d1
commit
a4c67614f7
@ -12,7 +12,7 @@ This is an experimental feature and has a number of [limitations](https://github
|
|||||||
## Import Waku SDK
|
## Import Waku SDK
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
npm install @waku/sdk@0.0.35-3e66a33.0
|
npm install @waku/sdk@0.0.35-4d5c152.0
|
||||||
```
|
```
|
||||||
|
|
||||||
Or using a CDN, note this is an ESM package so `type="module"` is needed.
|
Or using a CDN, note this is an ESM package so `type="module"` is needed.
|
||||||
@ -22,7 +22,7 @@ Or using a CDN, note this is an ESM package so `type="module"` is needed.
|
|||||||
import {
|
import {
|
||||||
createLightNode,
|
createLightNode,
|
||||||
ReliableChannel
|
ReliableChannel
|
||||||
} from 'https://unpkg.com/@waku/sdk@0.0.35-3e66a33.0/bundle/index.js';
|
} from 'https://unpkg.com/@waku/sdk@0.0.35-4d5c152.0/bundle/index.js';
|
||||||
|
|
||||||
// Your code here
|
// Your code here
|
||||||
|
|
||||||
@ -163,16 +163,14 @@ const protoMessage = DataPacket.create({
|
|||||||
const serialisedMessage = DataPacket.encode(protoMessage).finish();
|
const serialisedMessage = DataPacket.encode(protoMessage).finish();
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, setup listeners so you can know when the message:
|
Then, send the message and setup listeners so you can know when the message:
|
||||||
- has been sent
|
- has been sent
|
||||||
- has been acknowledged by other participants in the channel
|
- has been acknowledged by other participants in the channel
|
||||||
- has encountered an error
|
- has encountered an error
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { ReliableChannel } from "@waku/sdk";
|
// Send the message, and get the id to track events
|
||||||
|
const messageId = reliableChannel.send(payload);
|
||||||
// First, get the id to track the message
|
|
||||||
const messageId = ReliableChannel.getMessageId(serialisedMessage)
|
|
||||||
|
|
||||||
reliableChannel.addEventListener("sending-message-irrecoverable-error", (event) => {
|
reliableChannel.addEventListener("sending-message-irrecoverable-error", (event) => {
|
||||||
if (messageId === event.detail.messageId) {
|
if (messageId === event.detail.messageId) {
|
||||||
@ -194,12 +192,6 @@ reliableChannel.addEventListener("message-acknowledged", (event) => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
You are now ready to send the message:
|
|
||||||
|
|
||||||
```js
|
|
||||||
reliableChannel.send(payload);
|
|
||||||
```
|
|
||||||
|
|
||||||
:::tip Congratulations!
|
:::tip Congratulations!
|
||||||
You have successfully sent and received messages over the Waku Network using our reliable protocols such as Scalable Data Sync (SDS) and P2P Reliability.
|
You have successfully sent and received messages over the Waku Network using our reliable protocols such as Scalable Data Sync (SDS) and P2P Reliability.
|
||||||
:::
|
:::
|
||||||
Loading…
x
Reference in New Issue
Block a user