Add heartbeat

This commit is contained in:
Xin Wang
2026-02-04 23:16:30 +08:00
parent 77d54d284f
commit b72e09f263
3 changed files with 95 additions and 3 deletions

View File

@@ -179,6 +179,13 @@ class DTMFEvent(BaseEvent):
digit: str = Field(..., description="DTMF digit (0-9, *, #, A-D)")
class HeartBeatEvent(BaseModel):
"""Server-to-client heartbeat to keep connection alive."""
event: str = Field(default="heartBeat", description="Event type")
timestamp: int = Field(default_factory=current_timestamp_ms, description="Event timestamp in milliseconds")
# Event type mapping
EVENT_TYPES = {
"incoming": IncomingEvent,
@@ -198,6 +205,7 @@ EVENT_TYPES = {
"metrics": MetricsEvent,
"addHistory": AddHistoryEvent,
"dtmf": DTMFEvent,
"heartBeat": HeartBeatEvent,
}