Skip to content

Commit

Permalink
feat: dispatch session_close on close
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Sep 30, 2024
1 parent b0143a3 commit 24f3e97
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions redel/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ async def create_title_listener(self, event):

async def close(self):
"""Clean up all the app resources."""
self.dispatch(events.SessionClose(session_id=self.session_id))
await self.drain()
if self.dispatch_task is not None:
self.dispatch_task.cancel()
await asyncio.gather(
Expand Down
9 changes: 9 additions & 0 deletions redel/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ class RoundComplete(BaseEvent):
session_id: str


class SessionClose(BaseEvent):
"""The ReDel session is closing and clients should be redirected to the home page."""

__log_event__ = False

type: Literal["kani_message"] = "session_close"
session_id: str


# user events
class SendMessage(BaseEvent):
type: Literal["send_message"] = "send_message"
Expand Down

0 comments on commit 24f3e97

Please sign in to comment.