Skip to content

add user_data to on_message callbacks #178

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

Closed
vladak opened this issue Oct 25, 2023 · 2 comments
Closed

add user_data to on_message callbacks #178

vladak opened this issue Oct 25, 2023 · 2 comments

Comments

@vladak
Copy link
Contributor

vladak commented Oct 25, 2023

I have a use case for the "on_message" callback where it ought to set a local state based on received message contents. However, these callbacks do not receive the user_data argument like the other callbacks do. Adding the user_data as 2nd argument would break existing code, not sure what to do about that, otherwise I'd submit a PR right away. I'd say either bite the bullet or add another message callback, however the latter is complicated by the fact that there are 2 types of message callbacks - filtered and regular. To switch the behavior during runtime, the inspect module would be needed to get function signature, however I am not sure this is available in CP.

@vladak
Copy link
Contributor Author

vladak commented Oct 25, 2023

Another issue is that the call _handle_on_message() in _wait_for_msg() passes self needlessly.

vladak added a commit to vladak/Adafruit_CircuitPython_MiniMQTT that referenced this issue Oct 27, 2023
@ehagerty
Copy link

ehagerty commented Nov 6, 2023

this would be a fantastic addition - without it, utilising callbacks to process command messages (for example) to iot devices is a hassle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants