Skip to content

Commit

Permalink
Merge pull request #179 from vladak/handle_on_message_vs_self
Browse files Browse the repository at this point in the history
no need to pass self to _handle_on_message()
  • Loading branch information
brentru authored Oct 27, 2023
2 parents e7c2685 + 61dbdf0 commit 926846c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions adafruit_minimqtt/adafruit_minimqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,15 @@ def on_message(self):
def on_message(self, method) -> None:
self._on_message = method

def _handle_on_message(self, client, topic: str, message: str):
def _handle_on_message(self, topic: str, message: str):
matched = False
if topic is not None:
for callback in self._on_message_filtered.iter_match(topic):
callback(client, topic, message) # on_msg with callback
callback(self, topic, message) # on_msg with callback
matched = True

if not matched and self.on_message: # regular on_message
self.on_message(client, topic, message)
self.on_message(self, topic, message)

def username_pw_set(self, username: str, password: Optional[str] = None) -> None:
"""Set client's username and an optional password.
Expand Down Expand Up @@ -1072,7 +1072,7 @@ def _wait_for_msg(self) -> Optional[int]:
raw_msg = self._sock_exact_recv(sz)
msg = raw_msg if self._use_binary_mode else str(raw_msg, "utf-8")
self.logger.debug("Receiving PUBLISH \nTopic: %s\nMsg: %s\n", topic, raw_msg)
self._handle_on_message(self, topic, msg)
self._handle_on_message(topic, msg)
if res[0] & 0x06 == 0x02:
pkt = bytearray(b"\x40\x02\0\0")
struct.pack_into("!H", pkt, 2, pid)
Expand Down

0 comments on commit 926846c

Please sign in to comment.