2 Commits

2 changed files with 18 additions and 0 deletions

View File

@@ -181,3 +181,20 @@ class Message:
acknowledged=False,
ack_required=True,
)
@classmethod
def close(cls) -> Message:
"""Create a CLOSE message.
Prompts the recipient to close the connection and not reconnect.
Returns:
Message: The created CLOSE message.
"""
return cls(
id_=None,
category=Category.CONTROL,
action=ControlAction.CLOSE,
payload={},
acknowledged=False,
ack_required=True,
)

View File

@@ -13,3 +13,4 @@ class Category(str, Enum):
class ControlAction(str, Enum):
HELLO = "hello"
ACK = "ack"
CLOSE = "close"