Skip to content

Get incoming events only from async client #4

Open
@maxbull

Description

@maxbull

I use the AsyncClientMQTT of glazemq to subscribe specific topics. And I only want to handle the requests only because the subscribed topics are concerned only.

I know I cloud use match to deal with Incoming events only, like this:

  loop {
        match eventloop.poll().await {
            Ok(Event::Incoming(MqttPacket::Publish(p))) => {
                    println!("Incoming = {:?}, {:?}", p.topic, p.payload);
            },
            Ok(Event::Incoming(MqttPacket::Resp)) |
            Ok(Event::Outgoing(Outgoing::Req)) => {},
            Ok(Event::Incoming(i)) => {
                println!("Incoming = {:?}", i);
            },
            Ok(Event::Outgoing(o)) => {
                println!("Outgoing = {:?}", o);
            },
            Err(e) => {
                println!("Error = {:?}", e);
                // ERROR: Here I have to subscribe again to the topics :(
                client.subscribe("#", QoS::AtMostOnce).await.unwrap();
            }
        }

However, I'm interesting in way that allows to have solution or method that I can get the incoming events ONLY directly. Thanks

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Backlog

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions