Skip to content

Commit

Permalink
Simplify on connect (blakeblackshear#11176)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 authored Apr 30, 2024
1 parent 461442b commit 90bdb07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 0 additions & 4 deletions frigate/comms/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ def start(self) -> None:
class _WebSocketHandler(WebSocket): # type: ignore[misc]
receiver = self._dispatcher

def opened(self) -> None:
"""A new websocket is opened, we need to send an update message"""
threading.Timer(1.0, self.receiver, ("onConnect", "")).start()

def received_message(self, message: WebSocket.received_message) -> None:
try:
json_message = json.loads(message.data.decode("utf-8"))
Expand Down
8 changes: 7 additions & 1 deletion web/src/api/ws.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ function useValue(): useValueReturn {
setWsState({ ...wsState, [data.topic]: data.payload });
}
},
onOpen: () => {},
onOpen: () => {
sendJsonMessage({
topic: "onConnect",
message: "",
retain: false,
});
},
shouldReconnect: () => true,
});

Expand Down

0 comments on commit 90bdb07

Please sign in to comment.