bluerhinos / phpMQTT

a simple php class to connect/publish/subscribe to a MQTT broker
Other
773 stars 460 forks source link

subscribeAndWaitForMessage procudes wrong result #101

Open WolfspiritM opened 4 years ago

WolfspiritM commented 4 years ago

Hi,

subscribeAndWaitForMessage is not working as expected.

If it's used in a loop to get multiple messages it doesn't unsubscribe and if a previously subscribed message arrives from a different topic before the actual topic used in subscribeAndWaitForMessage it assume this one to be the correct one and returns a wrong result.

I fixed it by adding a unset($this->topics[$topic]); before the return in subscribeAndWaitForMessage