mirror of https://github.com/waku-org/js-waku.git
Examples: Content Topic moved out of options parameter
This commit is contained in:
parent
0cfdd34284
commit
9aaac20981
|
@ -104,10 +104,13 @@ export default async function startChat(): Promise<void> {
|
||||||
rl.prompt();
|
rl.prompt();
|
||||||
const chatMessage = ChatMessage.fromUtf8String(new Date(), nick, line);
|
const chatMessage = ChatMessage.fromUtf8String(new Date(), nick, line);
|
||||||
|
|
||||||
const msg = await WakuMessage.fromBytes(chatMessage.encode(), {
|
const msg = await WakuMessage.fromBytes(
|
||||||
contentTopic: ChatContentTopic,
|
chatMessage.encode(),
|
||||||
|
ChatContentTopic,
|
||||||
|
{
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
});
|
}
|
||||||
|
);
|
||||||
if (opts.lightPush) {
|
if (opts.lightPush) {
|
||||||
await waku.lightPush.push(msg);
|
await waku.lightPush.push(msg);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default function BroadcastPublicKey({
|
||||||
console.error('Failed to send Public Key Message', e);
|
console.error('Failed to send Public Key Message', e);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch(() => {
|
||||||
console.log('Failed to encode Public Key Message in Waku Message');
|
console.log('Failed to encode Public Key Message in Waku Message');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,7 +47,7 @@ export default function BroadcastPublicKey({
|
||||||
console.error('Failed to send Public Key Message', e);
|
console.error('Failed to send Public Key Message', e);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch(() => {
|
||||||
console.log(
|
console.log(
|
||||||
'Failed to encode Public Key Message in Waku Message'
|
'Failed to encode Public Key Message in Waku Message'
|
||||||
);
|
);
|
||||||
|
@ -75,7 +75,5 @@ async function encodePublicKeyWakuMessage(
|
||||||
publicKeyMessage: PublicKeyMessage
|
publicKeyMessage: PublicKeyMessage
|
||||||
): Promise<WakuMessage> {
|
): Promise<WakuMessage> {
|
||||||
const payload = publicKeyMessage.encode();
|
const payload = publicKeyMessage.encode();
|
||||||
return await WakuMessage.fromBytes(payload, {
|
return await WakuMessage.fromBytes(payload, PublicKeyContentTopic);
|
||||||
contentTopic: PublicKeyContentTopic,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,7 @@ async function encodeEncryptedWakuMessage(
|
||||||
});
|
});
|
||||||
|
|
||||||
const payload = directMsg.encode();
|
const payload = directMsg.encode();
|
||||||
return WakuMessage.fromBytes(payload, {
|
return WakuMessage.fromBytes(payload, DirectMessageContentTopic, {
|
||||||
contentTopic: DirectMessageContentTopic,
|
|
||||||
encPublicKey: publicKey,
|
encPublicKey: publicKey,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,11 @@ async function handleMessage(
|
||||||
} else {
|
} else {
|
||||||
const timestamp = new Date();
|
const timestamp = new Date();
|
||||||
const chatMessage = ChatMessage.fromUtf8String(timestamp, nick, message);
|
const chatMessage = ChatMessage.fromUtf8String(timestamp, nick, message);
|
||||||
const wakuMsg = await WakuMessage.fromBytes(chatMessage.encode(), {
|
const wakuMsg = await WakuMessage.fromBytes(
|
||||||
contentTopic: ChatContentTopic,
|
chatMessage.encode(),
|
||||||
timestamp,
|
ChatContentTopic,
|
||||||
});
|
{ timestamp }
|
||||||
|
);
|
||||||
return messageSender(wakuMsg);
|
return messageSender(wakuMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue