-
Notifications
You must be signed in to change notification settings - Fork 1
[RTC-365] Server notifications #8
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
Conversation
sgfn
left a comment
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.
Looks good -- I'm not too familiar with the notifications flow, but as far as I can tell, everything is as it should be. A couple nitpicks only
README.md
Outdated
| ``` | ||
|
|
||
| You can use it to interact with Jellyfish managing rooms, peers and components | ||
| You can use it to interact with Jellyfish, managing rooms, peers and components |
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.
| You can use it to interact with Jellyfish, managing rooms, peers and components | |
| You can use it to interact with Jellyfish, manage rooms, peers and components |
or ...Jellyfish, enabling the management of rooms..., now it sounds kinda weird.
jellyfish/_notifier.py
Outdated
| async with client.connect(f'ws://{self._server_address}/socket/server/websocket') \ | ||
| as websocket: |
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.
Nitpick, but I don't like the line break
| async with client.connect(f'ws://{self._server_address}/socket/server/websocket') \ | |
| as websocket: | |
| address = f'ws://{self._server_address}/socket/server/websocket' | |
| async with client.connect(address) as websocket: |
| if self._notification_handler: | ||
| await self._subscribe_event( | ||
| event=ServerMessageEventType.EVENT_TYPE_SERVER_NOTIFICATION) | ||
|
|
||
| if self._metrics_handler: | ||
| await self._subscribe_event(event=ServerMessageEventType.EVENT_TYPE_METRICS) |
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.
Does that mean that you cannot add handler after you have been connected? If so, I would mention it somewhere.
sgfn
left a comment
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.
Implemented Server Notifications using websockets and asyncio.
I recommend taking a look at the example in the Readme first.
The notification handling occurs as following:
on_server_notificationandon_metricsdecorators. Now the Notifier has designated handler for the given message types.If you are unfamiliar with asyncio, I recommend taking a look at their docs, for example here: https://docs.python.org/3/library/asyncio-task.html
INB4: I plan to add
secureoption to both RoomApi and Notifier but not in this PR