-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Notification monitoring system #21
Conversation
…o simple Queue system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all the commented code from metadata.py
The README should also be updated to provide an example of receiving a notification. It would be good to have some example code too, and some tests.
Essentially the stuff above in the How to verify it section should be finding its way into more obvious docs (like the README) rather than being buried in this PR. |
alvaro gave me the thumbs up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
- What I did
Implement AtMonitorConnection and notification monitoring system.
- How I did it
Took AtMonitorConnection.java as an example and implemented it, but used
locks
instead ofsynchronized
(because synchronized doesn't exist in Python, it needs to be created as a decorator).Created
AtEventType
enum and implemented an event system based on Queue library. There were EventBus solutions based onasyncio
lib, but I didn't find practical the added complexity of mixingThreading
andasyncio
for now.Created
AtEvent
class, which is essentially a wrapper forevent + data associated to the event
.AtEvent
objects are then introduced into theQueue
and read by other thread which will use that data.Added new parameters which will be eventually necessary to
Metadata
class (although they are commented because there's a circular import issue).TimeUtil
to manage milliseconds,SocketUtil
to createreadline()
method forSSLSocket
.Created
AtNotification
class, although it isn't used for now.Added
start_monitor
andstop_monitor
methods toAtClient
class, which can be used to start the monitoring for notifications. Addedhandle_event
method toAtClient
class.atconstants.py
is simply a file to define constants or global variables, such as locks or queues.Updated
repl.py
, which now includes a practical example of how this new feature can be used (simply create a new thread which calls a method, and handle the event reception through queues inside that method, also calling inside of it thehandle_event
method ofAtClient
class).Small tweaks not mentioned, feel free to ask.
Issues:
Metadata
circular imports exception if new code is uncommented.MONITOR_EXCEPTION
events triggered when reading@atSign@notification
notifications from yourself (doesn't happen with normalnotification
notifications also from yourself, which are actually the same as the other mentioned).handle_event
methods could be improved to a more abstract structure, although they work for now.- How to verify it
repl.py
and choose anatSign
using option1
2
. REPL will start and activate monitor mode automatically in a different thread. You can still send commands/verbs. You will start seeing your own notifications (from yourself to yourself) and heartbeat working (noop verb is sent from time to time as a keepalive)at_talk
or any other tool to send notifications to youratSign
from a differentatSign
. You should be able to see the complete notification, and the encrypted and decrypted value of it.- Description for the changelog
feat: Notification monitoring system
Progress in #8 and #9