Skip to content

no need to pass self to _handle_on_message() #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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