From f7144a57d9c27c351bd1ed103bd8a437d23a74e5 Mon Sep 17 00:00:00 2001 From: cnderrauber Date: Fri, 9 May 2025 10:23:47 +0800 Subject: [PATCH 1/3] Support moving participant to another room --- packages/livekit-server-sdk/package.json | 2 +- .../src/RoomServiceClient.ts | 21 +++++++++++++++++++ pnpm-lock.yaml | 10 ++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/livekit-server-sdk/package.json b/packages/livekit-server-sdk/package.json index 7ae6224b..83c46197 100644 --- a/packages/livekit-server-sdk/package.json +++ b/packages/livekit-server-sdk/package.json @@ -43,7 +43,7 @@ }, "dependencies": { "@bufbuild/protobuf": "^1.7.2", - "@livekit/protocol": "^1.36.1", + "@livekit/protocol": "^1.38.0", "camelcase-keys": "^9.0.0", "jose": "^5.1.2" }, diff --git a/packages/livekit-server-sdk/src/RoomServiceClient.ts b/packages/livekit-server-sdk/src/RoomServiceClient.ts index 9157f5bc..3a94e3aa 100644 --- a/packages/livekit-server-sdk/src/RoomServiceClient.ts +++ b/packages/livekit-server-sdk/src/RoomServiceClient.ts @@ -10,6 +10,7 @@ import { ListParticipantsResponse, ListRoomsRequest, ListRoomsResponse, + MoveParticipantRequest, MuteRoomTrackRequest, MuteRoomTrackResponse, ParticipantInfo, @@ -233,6 +234,9 @@ export class RoomServiceClient extends ServiceBase { * participant. When the source participant disconnects or the * `RemoveParticipant` method is called in the destination room, the * forwarding will be stopped. + * @param room - + * @param identity - + * @param destinationRoom - the room to forward the participant to */ async forwardParticipant(room: string, identity: string, destinationRoom: string): Promise { await this.rpc.request( @@ -243,6 +247,23 @@ export class RoomServiceClient extends ServiceBase { ); } + /** + * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`. + * The participant will be removed from the current room and added to the destination room. + * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one. + * @param room - + * @param identity - + * @param destinationRoom - the room to move the participant to + */ + async moveParticipant(room: string, identity: string, destinationRoom: string): Promise { + await this.rpc.request( + svc, + 'MoveParticipant', + new MoveParticipantRequest({ room, identity, destinationRoom, }).toJson(), + await this.authHeader({ roomAdmin: true, room, destinationRoom }), + ); + } + /** * Mutes a track that the participant has published. * @param room - diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a1e1a67d..297cfd92 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -270,8 +270,8 @@ importers: specifier: ^1.7.2 version: 1.10.0 '@livekit/protocol': - specifier: ^1.36.1 - version: 1.36.1 + specifier: ^1.38.0 + version: 1.38.0 camelcase-keys: specifier: ^9.0.0 version: 9.1.3 @@ -956,8 +956,8 @@ packages: '@livekit/protocol@1.35.0': resolution: {integrity: sha512-uVVfQQr9JlsE+WBKbMgMdsxuVCG2zYkcE52bOjRQiGQvdbj9dm90A7sy+G7Vrb0QPGaN30xlI7nvtKpcGqw9Nw==} - '@livekit/protocol@1.36.1': - resolution: {integrity: sha512-nN3QnITAQ5yXk7UKfotH7CRWIlEozNWeKVyFJ0/+dtSzvWP/ib+10l1DDnRYi3A1yICJOGAKFgJ5d6kmi1HCUA==} + '@livekit/protocol@1.38.0': + resolution: {integrity: sha512-XX6ulvsE1XCN18LVf3ydHN7Ri1Z1M1P5dQdjnm5nVDsSqUL12Vbo/4RKcRlCEXAg2qB62mKjcaVLXVwkfXggkg==} '@livekit/typed-emitter@3.0.0': resolution: {integrity: sha512-9bl0k4MgBPZu3Qu3R3xy12rmbW17e3bE9yf4YY85gJIQ3ezLEj/uzpKHWBsLaDoL5Mozz8QCgggwIBudYQWeQg==} @@ -4163,7 +4163,7 @@ snapshots: dependencies: '@bufbuild/protobuf': 1.10.0 - '@livekit/protocol@1.36.1': + '@livekit/protocol@1.38.0': dependencies: '@bufbuild/protobuf': 1.10.0 From 1b241ad73fef670b5ae3cff70e714ed48e71bea7 Mon Sep 17 00:00:00 2001 From: cnderrauber Date: Fri, 9 May 2025 10:36:19 +0800 Subject: [PATCH 2/3] changeset --- .changeset/loud-seas-sniff.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/loud-seas-sniff.md diff --git a/.changeset/loud-seas-sniff.md b/.changeset/loud-seas-sniff.md new file mode 100644 index 00000000..5fee7009 --- /dev/null +++ b/.changeset/loud-seas-sniff.md @@ -0,0 +1,5 @@ +--- +'livekit-server-sdk': minor +--- + +Support moving participant to another room From b78c2200ee9485820bf0ace5a5b389821b2dc966 Mon Sep 17 00:00:00 2001 From: cnderrauber Date: Fri, 9 May 2025 10:43:29 +0800 Subject: [PATCH 3/3] prettier --- packages/livekit-server-sdk/src/RoomServiceClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/livekit-server-sdk/src/RoomServiceClient.ts b/packages/livekit-server-sdk/src/RoomServiceClient.ts index 3a94e3aa..2a17e575 100644 --- a/packages/livekit-server-sdk/src/RoomServiceClient.ts +++ b/packages/livekit-server-sdk/src/RoomServiceClient.ts @@ -259,7 +259,7 @@ export class RoomServiceClient extends ServiceBase { await this.rpc.request( svc, 'MoveParticipant', - new MoveParticipantRequest({ room, identity, destinationRoom, }).toJson(), + new MoveParticipantRequest({ room, identity, destinationRoom }).toJson(), await this.authHeader({ roomAdmin: true, room, destinationRoom }), ); }