fix(example): only attempt to decode messages sent in the toy chat content topic
This commit is contained in:
parent
d7cbdc2658
commit
b09f834fe4
|
@ -134,6 +134,10 @@ fn main() -> std::result::Result<(), Box<dyn Error>> {
|
||||||
let shared_messages = Arc::clone(&app.messages);
|
let shared_messages = Arc::clone(&app.messages);
|
||||||
waku_set_event_callback(move |signal| match signal.event() {
|
waku_set_event_callback(move |signal| match signal.event() {
|
||||||
waku_bindings::Event::WakuMessage(event) => {
|
waku_bindings::Event::WakuMessage(event) => {
|
||||||
|
if event.waku_message().content_topic() != &TOY_CHAT_CONTENT_TOPIC {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
match <Chat2Message as Message>::decode(event.waku_message().payload()) {
|
match <Chat2Message as Message>::decode(event.waku_message().payload()) {
|
||||||
Ok(chat_message) => {
|
Ok(chat_message) => {
|
||||||
shared_messages.write().unwrap().push(chat_message);
|
shared_messages.write().unwrap().push(chat_message);
|
||||||
|
|
Loading…
Reference in New Issue