Merge pull request #3992 from JustAnotherArchivist/ws-message-timestamp-float

Record float timestamp for WebSocket messages instead of truncating to int
This commit is contained in:
Maximilian Hils 2020-05-13 16:11:15 +02:00 committed by GitHub
commit b4bd1741eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -17,7 +17,7 @@ class WebSocketMessage(serializable.Serializable):
""" """
def __init__( def __init__(
self, type: int, from_client: bool, content: bytes, timestamp: Optional[int]=None, killed: bool=False self, type: int, from_client: bool, content: bytes, timestamp: Optional[float]=None, killed: bool=False
) -> None: ) -> None:
self.type = Opcode(type) # type: ignore self.type = Opcode(type) # type: ignore
"""indicates either TEXT or BINARY (from wsproto.frame_protocol.Opcode).""" """indicates either TEXT or BINARY (from wsproto.frame_protocol.Opcode)."""
@ -25,7 +25,7 @@ class WebSocketMessage(serializable.Serializable):
"""True if this messages was sent by the client.""" """True if this messages was sent by the client."""
self.content = content self.content = content
"""A byte-string representing the content of this message.""" """A byte-string representing the content of this message."""
self.timestamp: int = timestamp or int(time.time()) self.timestamp: float = timestamp or time.time()
"""Timestamp of when this message was received or created.""" """Timestamp of when this message was received or created."""
self.killed = killed self.killed = killed
"""True if this messages was killed and should not be sent to the other endpoint.""" """True if this messages was killed and should not be sent to the other endpoint."""