Skip to content
Open
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
11 changes: 9 additions & 2 deletions summoner/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import json
from typing import (
Optional,
Callable,
Callable,
TypedDict,
Union,
Awaitable,
Any,
Expand Down Expand Up @@ -51,6 +52,12 @@
recover_with_types,
)

class WrappedPayload(TypedDict):
"""Defines the server's message envelope, including sender address and content."""
remote_addr: str
# If the content is readable as JSON, it will be a dict; otherwise, a string
content: Union[str, dict]

class ServerDisconnected(Exception):
"""Raised when the server closes the connection."""
pass
Expand Down Expand Up @@ -358,7 +365,7 @@ def receive(
priority: Union[int, tuple[int, ...]] = ()
):
route = route.strip()
def decorator(fn: Callable[[Union[str, dict]], Awaitable[Optional[Event]]]):
def decorator(fn: Callable[[WrappedPayload], Awaitable[Optional[Event]]]):

# ----[ Safety Checks ]----

Expand Down