moonraker: send status eventtime as a second parameter to "notify_status_update"
This resolves a potential issue where clients could anticipate that all items in the status parameter are objects. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
81854d1daf
commit
c6fee3c1f4
|
@ -191,7 +191,10 @@ class KlippyAPI(Subscribable):
|
|||
{'response_template': {"method": method_name},
|
||||
'remote_method': method_name})
|
||||
|
||||
def send_status(self, status: Dict[str, Any]) -> None:
|
||||
def send_status(self,
|
||||
status: Dict[str, Any],
|
||||
eventtime: float
|
||||
) -> None:
|
||||
self.server.send_event("server:status_update", status)
|
||||
|
||||
def load_component(config: ConfigHelper) -> KlippyAPI:
|
||||
|
|
|
@ -469,8 +469,7 @@ class Server:
|
|||
else:
|
||||
conn_status[name] = {
|
||||
k: v for k, v in val.items() if k in fields}
|
||||
conn_status['eventtime'] = eventtime
|
||||
conn.send_status(conn_status)
|
||||
conn.send_status(conn_status, eventtime)
|
||||
|
||||
async def make_request(self, web_request: WebRequest) -> Any:
|
||||
rpc_method = web_request.get_endpoint()
|
||||
|
|
|
@ -42,7 +42,10 @@ if TYPE_CHECKING:
|
|||
SENTINEL = SentinelClass.get_instance()
|
||||
|
||||
class Subscribable:
|
||||
def send_status(self, status: Dict[str, Any]) -> None:
|
||||
def send_status(self,
|
||||
status: Dict[str, Any],
|
||||
eventtime: float
|
||||
) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
class WebRequest:
|
||||
|
@ -428,13 +431,16 @@ class WebSocket(WebSocketHandler, Subscribable):
|
|||
f"Error sending data over websocket: {self.uid}")
|
||||
self.queue_busy = False
|
||||
|
||||
def send_status(self, status: Dict[str, Any]) -> None:
|
||||
def send_status(self,
|
||||
status: Dict[str, Any],
|
||||
eventtime: float
|
||||
) -> None:
|
||||
if not status:
|
||||
return
|
||||
self.queue_message({
|
||||
'jsonrpc': "2.0",
|
||||
'method': "notify_status_update",
|
||||
'params': [status]})
|
||||
'params': [status, eventtime]})
|
||||
|
||||
def on_close(self) -> None:
|
||||
self.is_closed = True
|
||||
|
|
Loading…
Reference in New Issue