feat: Process boolean True responses over Packet Stream

This commit is contained in:
Gergely Polonkai 2023-11-18 07:06:10 +01:00
parent 9b54ea6cec
commit d6881cd8d5
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
2 changed files with 9 additions and 3 deletions

View File

@ -184,7 +184,7 @@ class MuxRPCMessage:
return cls(message.body)
def __init__(self, body: Union[bytes, str, Dict[str, Any]]):
def __init__(self, body: Union[bytes, str, Dict[str, Any], bool]):
self.body = body
def __repr__(self) -> str:

View File

@ -131,6 +131,9 @@ class PSMessage:
def data(self) -> bytes:
"""The raw message data"""
if self.body is True:
return b"true"
if self.type == PSMessageType.TEXT:
assert isinstance(self.body, str)
@ -147,7 +150,7 @@ class PSMessage:
def __init__(
self,
type_: PSMessageType,
body: Union[bytes, str, Dict[str, Any]],
body: Union[bytes, str, Dict[str, Any], bool],
stream: bool,
end_err: bool,
req: Optional[int] = None,
@ -159,7 +162,10 @@ class PSMessage:
self.req = req
def __repr__(self) -> str:
if self.type == PSMessageType.BUFFER:
if self.body is True:
body = "EOF"
elif self.type == PSMessageType.BUFFER:
assert isinstance(self.body, bytes)
body = f"{len(self.body)} bytes"
else:
body = str(self.body)