From 97269a7c20147c582c6b892febff4e23d1cbdff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=CC=81o=20Monnom?= Date: Thu, 7 Nov 2024 17:53:31 -0600 Subject: [PATCH 1/3] Update event_emitter.py --- livekit-rtc/livekit/rtc/event_emitter.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/livekit-rtc/livekit/rtc/event_emitter.py b/livekit-rtc/livekit/rtc/event_emitter.py index 44f3ef2e..53e8c67b 100644 --- a/livekit-rtc/livekit/rtc/event_emitter.py +++ b/livekit-rtc/livekit/rtc/event_emitter.py @@ -3,17 +3,17 @@ from .log import logger -T = TypeVar("T") +T_contra = TypeVar("T_contra", contravariant=True) -class EventEmitter(Generic[T]): +class EventEmitter(Generic[T_contra]): def __init__(self) -> None: """ Initialize a new instance of EventEmitter. """ - self._events: Dict[T, Set[Callable]] = dict() + self._events: Dict[T_contra, Set[Callable]] = dict() - def emit(self, event: T, *args) -> None: + def emit(self, event: T_contra, *args) -> None: """ Trigger all callbacks associated with the given event. @@ -60,7 +60,7 @@ def greet(name): except Exception: logger.exception(f"failed to emit event {event}") - def once(self, event: T, callback: Optional[Callable] = None) -> Callable: + def once(self, event: T_contra, callback: Optional[Callable] = None) -> Callable: """ Register a callback to be called only once when the event is emitted. @@ -116,7 +116,7 @@ def decorator(callback: Callable) -> Callable: return decorator - def on(self, event: T, callback: Optional[Callable] = None) -> Callable: + def on(self, event: T_contra, callback: Optional[Callable] = None) -> Callable: """ Register a callback to be called whenever the event is emitted. @@ -168,7 +168,7 @@ def decorator(callback: Callable) -> Callable: return decorator - def off(self, event: T, callback: Callable) -> None: + def off(self, event: T_contra, callback: Callable) -> None: """ Unregister a callback from an event. From e9e536c1275b32b000074795ee61b9623df5a2f0 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:54:20 +0000 Subject: [PATCH 2/3] generated protobuf --- livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi | 2 +- livekit-rtc/livekit/rtc/_proto/handle_pb2.pyi | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi b/livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi index 6af677fe..5799ce3f 100644 --- a/livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi +++ b/livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi @@ -63,7 +63,7 @@ global___LogLevel = LogLevel class FfiRequest(google.protobuf.message.Message): """**How is the livekit-ffi working: We refer as the ffi server the Rust server that is running the LiveKit client implementation, and we - refer as the ffi client the foreign language that communicates with the ffi server. (e.g. Python SDK, Unity SDK, etc...) + refer as the ffi client the foreign language that commumicates with the ffi server. (e.g Python SDK, Unity SDK, etc...) We expose the Rust client implementation of livekit using the protocol defined here. Everything starts with a FfiRequest, which is a oneof message that contains all the possible diff --git a/livekit-rtc/livekit/rtc/_proto/handle_pb2.pyi b/livekit-rtc/livekit/rtc/_proto/handle_pb2.pyi index 750b8476..ce29050f 100644 --- a/livekit-rtc/livekit/rtc/_proto/handle_pb2.pyi +++ b/livekit-rtc/livekit/rtc/_proto/handle_pb2.pyi @@ -26,13 +26,13 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final class FfiOwnedHandle(google.protobuf.message.Message): """# Safety - The foreign language is responsible for disposing handles + The foreign language is responsable for disposing handles Forgetting to dispose the handle may lead to memory leaks Dropping a handle doesn't necessarily mean that the object is destroyed if it is still used on the FfiServer (Atomic reference counting) - When referring to a handle without owning it, we just use an uint32 without this message. + When refering to a handle without owning it, we just use a uint32 without this message. (the variable name is suffixed with "_handle") """ From e4b814855e5e8559d88fc3c0d34a056334516ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=CC=81o=20Monnom?= Date: Thu, 7 Nov 2024 17:56:24 -0600 Subject: [PATCH 3/3] Update access_token.py --- livekit-api/livekit/api/access_token.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/livekit-api/livekit/api/access_token.py b/livekit-api/livekit/api/access_token.py index 1450ebb8..9668296a 100644 --- a/livekit-api/livekit/api/access_token.py +++ b/livekit-api/livekit/api/access_token.py @@ -154,9 +154,13 @@ def to_jwt(self) -> str: { "sub": self.identity, "iss": self.api_key, - "nbf": calendar.timegm(datetime.datetime.now(datetime.timezone.utc).utctimetuple()), + "nbf": calendar.timegm( + datetime.datetime.now(datetime.timezone.utc).utctimetuple() + ), "exp": calendar.timegm( - (datetime.datetime.now(datetime.timezone.utc) + self.ttl).utctimetuple() + ( + datetime.datetime.now(datetime.timezone.utc) + self.ttl + ).utctimetuple() ), } )