This commit is contained in:
Freddy Boulton
2025-03-28 21:12:58 -04:00
committed by GitHub
parent 8ed27fba78
commit f742c93235
4 changed files with 44 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import logging
import tempfile
import traceback
from contextvars import ContextVar
from dataclasses import dataclass
from typing import Any, Callable, Literal, Protocol, TypedDict, cast
import av
@@ -61,6 +62,22 @@ current_channel: ContextVar[DataChannel | None] = ContextVar(
)
@dataclass
class Context:
webrtc_id: str
current_context: ContextVar[Context | None] = ContextVar(
"current_context", default=None
)
def get_current_context() -> Context:
if not (ctx := current_context.get()):
raise RuntimeError("No context found")
return ctx
def _send_log(message: str, type: str) -> None:
async def _send(channel: DataChannel) -> None:
channel.send(