Skip to content

Commit

Permalink
remove chat references in message structure
Browse files Browse the repository at this point in the history
  • Loading branch information
LordGhostX committed Jun 11, 2024
1 parent 0f4ae4c commit 7f4ac16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/guides/js-waku/light-send-receive.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Create your application's message structure using [Protobuf's valid message](htt
import protobuf from "protobufjs";

// Create a message structure using Protobuf
const ChatMessage = new protobuf.Type("ChatMessage")
const DataPacket = new protobuf.Type("DataPacket")
.add(new protobuf.Field("timestamp", 1, "uint64"))
.add(new protobuf.Field("sender", 2, "string"))
.add(new protobuf.Field("message", 3, "string"));
Expand All @@ -123,14 +123,14 @@ To send messages over the Waku Network using the `Light Push` protocol, create a

```js
// Create a new message object
const protoMessage = ChatMessage.create({
const protoMessage = DataPacket.create({
timestamp: Date.now(),
sender: "Alice",
message: "Hello, World!",
});

// Serialise the message using Protobuf
const serialisedMessage = ChatMessage.encode(protoMessage).finish();
const serialisedMessage = DataPacket.encode(protoMessage).finish();

// Send the message using Light Push
await node.lightPush.send(encoder, {
Expand All @@ -148,7 +148,7 @@ const callback = (wakuMessage) => {
// Check if there is a payload on the message
if (!wakuMessage.payload) return;
// Render the messageObj as desired in your application
const messageObj = ChatMessage.decode(wakuMessage.payload);
const messageObj = DataPacket.decode(wakuMessage.payload);
console.log(messageObj);
};

Expand Down
12 changes: 6 additions & 6 deletions docs/guides/js-waku/use-waku-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function App() {
const decoder = createDecoder(contentTopic);

// Create a message structure using Protobuf
const ChatMessage = new protobuf.Type("ChatMessage")
const DataPacket = new protobuf.Type("DataPacket")
.add(new protobuf.Field("timestamp", 1, "uint64"))
.add(new protobuf.Field("message", 2, "string"));

Expand Down Expand Up @@ -223,13 +223,13 @@ function App() {

// Create a new message object
const timestamp = Date.now();
const protoMessage = ChatMessage.create({
const protoMessage = DataPacket.create({
timestamp: timestamp,
message: inputMessage
});

// Serialise the message and push to the network
const payload = ChatMessage.encode(protoMessage).finish();
const payload = DataPacket.encode(protoMessage).finish();
const { recipients, errors } = await push({ payload, timestamp });

// Check for errors
Expand Down Expand Up @@ -258,7 +258,7 @@ function App() {
useEffect(() => {
setMessages(filterMessages.map((wakuMessage) => {
if (!wakuMessage.payload) return;
return ChatMessage.decode(wakuMessage.payload);
return DataPacket.decode(wakuMessage.payload);
}));
}, [filterMessages]);
}
Expand All @@ -283,7 +283,7 @@ function App() {
const allMessages = storeMessages.concat(filterMessages);
setMessages(allMessages.map((wakuMessage) => {
if (!wakuMessage.payload) return;
return ChatMessage.decode(wakuMessage.payload);
return DataPacket.decode(wakuMessage.payload);
}));
}, [filterMessages, storeMessages]);
}
Expand All @@ -295,4 +295,4 @@ To explore the available Store query options, have a look at the [Retrieve Messa

:::tip
You have successfully integrated `@waku/sdk` into a React application using the `@waku/react` package. Have a look at the [web-chat](https://github.com/waku-org/js-waku-examples/tree/master/examples/web-chat) example for a working demo and the [Building a Tic-Tac-Toe Game with Waku](https://blog.waku.org/tictactoe-tutorial) tutorial to learn more.
:::
:::

0 comments on commit 7f4ac16

Please sign in to comment.