-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
livekit-client should export TrackType
for seamless communication with livekit-server-sdk backend
#1369
Comments
As a suggestion i created #1370. However i would understand if the livekit core team would refrain from exposing more types from I'm wondering though: what is the concrete reason that livekit-client duplicates all these types from the protocol package ( IMHO it would be preferable to only rely on the types from |
@davidzhao @momenthana thanks for merging #1370, which solves our issue for the time being.
Just BTW –
Would be keen to follow up on this point and learn the LiveKit SDK teams' take on these. |
Describe the bug
Following the discussion at #1355 (comment) i went ahead and tried to replace
TrackType
(imported from the transitive dependency@livekit/protocol
which following this comment should be discouraged / not necessary) withTrack.Kind
orTrack.Source
and came to realize that this is not viable for us.Explanation
Our backend implements a service – which maps type-safe as a GraphQL-mutation to the frontend – like this:
Evaluating the possible alternatives to
TrackType
here:track.type
here istrack.source
– but that is not what we want here, as – compared toTrackType
theTrackSource
type is less deterministic (i.e. it hasTrackSource.UNKNOWN
which we wouldn't known how to handle here) and also the source of the track is not relevant to this mutation at all.Track.Source
in livekit-client does not map toTrackSource
from livekit-server-sdk/protocol at all … it's actually a pitfall, b/c the former is an enum mapping to string values, while the latter is an enum mapping to integers.We could use
Track.sourceToProto(s: Source)
here, but that is an internal method and also seems more complex than necessary.TrackKind
doesn't seem exposed at this point at all – but even if it was, it bears the same caveat regarding type mismatch than above –Track.Kind
from livekit-client is a string-enum, whileTrackKind
from livekit-server-sdk is integer-based. Again, it also hasTrack.Kind.Unknown
(TrackKind.UNKNOWN
) respectively, which we don't exactly know what to make out of it.Again,
Track.kindToProto(k: Kind)
could be used in livekit-client, but i don't believe that's an option that the designers of the SDK would want to encourage.muteParticipantAudio({roomName, identity})
andmuteParticipantVideo({roomName, identity})
services. While this seems a clear straightforward solution it effectively duplicates everything on top of the service layer: the generated type code, the gql query code, the mutation callbacks, which is why the current solution is preferable.@livekit/protocol
Summing up, it looks like simply exporting
TrackType
from livekit-client seems the most straightforward and easiest measure to ensure seamless interop between livekit-client and livekit-server-sdk.Of course, happy to learn if there's an option i have overlooked here.
Reproduction
_
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: