Skip to content
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

Add dedicated chat API #1224

Merged
merged 8 commits into from
Sep 24, 2024
Merged

Add dedicated chat API #1224

merged 8 commits into from
Sep 24, 2024

Conversation

lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Aug 14, 2024

depends on livekit/protocol#785

worth discussing:
should the client-sdk-js already hold an array of all incoming chat messages or is that left to components and/or user land?

Copy link

changeset-bot bot commented Aug 14, 2024

🦋 Changeset detected

Latest commit: 6a7a15f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lukasIO lukasIO assigned davidzhao and unassigned davidzhao Sep 18, 2024
@lukasIO lukasIO marked this pull request as ready for review September 18, 2024 13:56
Copy link
Contributor

github-actions bot commented Sep 19, 2024

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 83.24 KB (+1.22% 🔺)
dist/livekit-client.umd.js 89.14 KB (+1.17% 🔺)

Copy link
Contributor

@bcherry bcherry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, some non-blocker questions

@@ -519,6 +520,9 @@ export enum ParticipantEvent {
* fired on local participant only, when the first remote participant has subscribed to the track specified in the payload
*/
LocalTrackSubscribed = 'localTrackSubscribed',

/** only emitted on local participant */
ChatMessage = 'chatMessage',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe should be called ChatMessageReceived? Might also clear up some confusion to split it into ChatMessageReceived and ChatMessageSent

Copy link
Contributor Author

@lukasIO lukasIO Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was trying to avoid having two different events for sent and received because it generally generates more boilerplate when having to listen to two different events. The second argument that lead me to try to combine the events under one name was that when differentiating between sent and received we'd also have to consider a different event for updated.
I'm not sure though it's the right call to combine them. Considering the reasoning above, what's your opinion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see - I was confused.

Maybe the ParticipantEvent one should be called localChatMessageSent, since that's all its used for and it would then align perfectly with its handler, onLocalChatMessageSent.

The RoomEvent one stay as chatMessage but you should add a comment explaining that its emitted for chat messages sent, received, and updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds like a good idea!

@@ -519,6 +520,9 @@ export enum ParticipantEvent {
* fired on local participant only, when the first remote participant has subscribed to the track specified in the payload
*/
LocalTrackSubscribed = 'localTrackSubscribed',

/** only emitted on local participant */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this comment right? it looks like it's emitted on room, with participant in the args

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's defined both on RoomEvents and ParticipantEvents. This comment is for the ParticipantEvent.ChatMessage, so it's correct here.

src/room/types.ts Outdated Show resolved Hide resolved
@lukasIO lukasIO merged commit 4a424df into main Sep 24, 2024
3 checks passed
@lukasIO lukasIO deleted the lukas/chat-apis branch September 24, 2024 06:45
@github-actions github-actions bot mentioned this pull request Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants