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},
|
{'response_template': {"method": method_name},
|
||||||
'remote_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)
|
self.server.send_event("server:status_update", status)
|
||||||
|
|
||||||
def load_component(config: ConfigHelper) -> KlippyAPI:
|
def load_component(config: ConfigHelper) -> KlippyAPI:
|
||||||
|
|
|
@ -469,8 +469,7 @@ class Server:
|
||||||
else:
|
else:
|
||||||
conn_status[name] = {
|
conn_status[name] = {
|
||||||
k: v for k, v in val.items() if k in fields}
|
k: v for k, v in val.items() if k in fields}
|
||||||
conn_status['eventtime'] = eventtime
|
conn.send_status(conn_status, eventtime)
|
||||||
conn.send_status(conn_status)
|
|
||||||
|
|
||||||
async def make_request(self, web_request: WebRequest) -> Any:
|
async def make_request(self, web_request: WebRequest) -> Any:
|
||||||
rpc_method = web_request.get_endpoint()
|
rpc_method = web_request.get_endpoint()
|
||||||
|
|
|
@ -42,7 +42,10 @@ if TYPE_CHECKING:
|
||||||
SENTINEL = SentinelClass.get_instance()
|
SENTINEL = SentinelClass.get_instance()
|
||||||
|
|
||||||
class Subscribable:
|
class Subscribable:
|
||||||
def send_status(self, status: Dict[str, Any]) -> None:
|
def send_status(self,
|
||||||
|
status: Dict[str, Any],
|
||||||
|
eventtime: float
|
||||||
|
) -> None:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
class WebRequest:
|
class WebRequest:
|
||||||
|
@ -428,13 +431,16 @@ class WebSocket(WebSocketHandler, Subscribable):
|
||||||
f"Error sending data over websocket: {self.uid}")
|
f"Error sending data over websocket: {self.uid}")
|
||||||
self.queue_busy = False
|
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:
|
if not status:
|
||||||
return
|
return
|
||||||
self.queue_message({
|
self.queue_message({
|
||||||
'jsonrpc': "2.0",
|
'jsonrpc': "2.0",
|
||||||
'method': "notify_status_update",
|
'method': "notify_status_update",
|
||||||
'params': [status]})
|
'params': [status, eventtime]})
|
||||||
|
|
||||||
def on_close(self) -> None:
|
def on_close(self) -> None:
|
||||||
self.is_closed = True
|
self.is_closed = True
|
||||||
|
|
Loading…
Reference in New Issue