2024-03-23 17:11:32 +01:00
|
|
|
"""Facilitates communication between processes."""
|
|
|
|
|
|
|
|
from frigate.events.types import EventStateEnum, EventTypeEnum
|
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
from .zmq_proxy import Publisher, Subscriber
|
2024-03-23 17:11:32 +01:00
|
|
|
|
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
class EventUpdatePublisher(Publisher):
|
2024-03-23 17:11:32 +01:00
|
|
|
"""Publishes events (objects, audio, manual)."""
|
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
topic_base = "event/"
|
|
|
|
|
2024-03-23 17:11:32 +01:00
|
|
|
def __init__(self) -> None:
|
2024-06-21 23:30:19 +02:00
|
|
|
super().__init__("update")
|
2024-03-23 17:11:32 +01:00
|
|
|
|
|
|
|
def publish(
|
|
|
|
self, payload: tuple[EventTypeEnum, EventStateEnum, str, dict[str, any]]
|
|
|
|
) -> None:
|
2024-06-21 23:30:19 +02:00
|
|
|
super().publish(payload)
|
2024-03-23 17:11:32 +01:00
|
|
|
|
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
class EventUpdateSubscriber(Subscriber):
|
2024-03-23 17:11:32 +01:00
|
|
|
"""Receives event updates."""
|
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
topic_base = "event/"
|
2024-04-09 01:19:45 +02:00
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
def __init__(self) -> None:
|
|
|
|
super().__init__("update")
|
2024-04-09 01:19:45 +02:00
|
|
|
|
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
class EventEndPublisher(Publisher):
|
2024-04-09 01:19:45 +02:00
|
|
|
"""Publishes events that have ended."""
|
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
topic_base = "event/"
|
|
|
|
|
2024-04-09 01:19:45 +02:00
|
|
|
def __init__(self) -> None:
|
2024-06-21 23:30:19 +02:00
|
|
|
super().__init__("finalized")
|
2024-04-09 01:19:45 +02:00
|
|
|
|
|
|
|
def publish(
|
|
|
|
self, payload: tuple[EventTypeEnum, EventStateEnum, str, dict[str, any]]
|
|
|
|
) -> None:
|
2024-06-21 23:30:19 +02:00
|
|
|
super().publish(payload)
|
2024-04-09 01:19:45 +02:00
|
|
|
|
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
class EventEndSubscriber(Subscriber):
|
2024-04-09 01:19:45 +02:00
|
|
|
"""Receives events that have ended."""
|
|
|
|
|
2024-06-21 23:30:19 +02:00
|
|
|
topic_base = "event/"
|
|
|
|
|
2024-04-09 01:19:45 +02:00
|
|
|
def __init__(self) -> None:
|
2024-06-21 23:30:19 +02:00
|
|
|
super().__init__("finalized")
|