diff --git a/protobufs/rpc/room.proto b/protobufs/rpc/room.proto index 8a4c47a11..fd970e09e 100644 --- a/protobufs/rpc/room.proto +++ b/protobufs/rpc/room.proto @@ -53,4 +53,24 @@ service Room { }; }; }; + rpc ListParticipants(livekit.ListParticipantsRequest) returns (livekit.ListParticipantsResponse) { + option (psrpc.options) = { + topics: true + topic_params: { + group: "room" + names: ["room"] + typed: true + }; + }; + }; + rpc GetParticipant(livekit.RoomParticipantIdentity) returns (livekit.ParticipantInfo) { + option (psrpc.options) = { + topics: true + topic_params: { + group: "room" + names: ["room"] + typed: true + }; + }; + }; } diff --git a/rpc/room.psrpc.go b/rpc/room.psrpc.go index 73621bcc7..72b3da5ef 100644 --- a/rpc/room.psrpc.go +++ b/rpc/room.psrpc.go @@ -29,6 +29,10 @@ type RoomClient[RoomTopicType ~string] interface { UpdateRoomMetadata(ctx context.Context, room RoomTopicType, req *livekit6.UpdateRoomMetadataRequest, opts ...psrpc.RequestOption) (*livekit1.Room, error) + ListParticipants(ctx context.Context, room RoomTopicType, req *livekit6.ListParticipantsRequest, opts ...psrpc.RequestOption) (*livekit6.ListParticipantsResponse, error) + + GetParticipant(ctx context.Context, room RoomTopicType, req *livekit6.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit6.ParticipantInfo, error) + // Close immediately, without waiting for pending RPCs Close() } @@ -43,6 +47,10 @@ type RoomServerImpl interface { SendData(context.Context, *livekit6.SendDataRequest) (*livekit6.SendDataResponse, error) UpdateRoomMetadata(context.Context, *livekit6.UpdateRoomMetadataRequest) (*livekit1.Room, error) + + ListParticipants(context.Context, *livekit6.ListParticipantsRequest) (*livekit6.ListParticipantsResponse, error) + + GetParticipant(context.Context, *livekit6.RoomParticipantIdentity) (*livekit6.ParticipantInfo, error) } // ===================== @@ -56,6 +64,10 @@ type RoomServer[RoomTopicType ~string] interface { DeregisterSendDataTopic(room RoomTopicType) RegisterUpdateRoomMetadataTopic(room RoomTopicType) error DeregisterUpdateRoomMetadataTopic(room RoomTopicType) + RegisterListParticipantsTopic(room RoomTopicType) error + DeregisterListParticipantsTopic(room RoomTopicType) + RegisterGetParticipantTopic(room RoomTopicType) error + DeregisterGetParticipantTopic(room RoomTopicType) RegisterAllRoomTopics(room RoomTopicType) error DeregisterAllRoomTopics(room RoomTopicType) @@ -84,6 +96,8 @@ func NewRoomClient[RoomTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.Cl sd.RegisterMethod("DeleteRoom", false, false, true, true) sd.RegisterMethod("SendData", false, false, true, true) sd.RegisterMethod("UpdateRoomMetadata", false, false, true, true) + sd.RegisterMethod("ListParticipants", false, false, true, true) + sd.RegisterMethod("GetParticipant", false, false, true, true) rpcClient, err := client.NewRPCClient(sd, bus, opts...) if err != nil { @@ -107,6 +121,14 @@ func (c *roomClient[RoomTopicType]) UpdateRoomMetadata(ctx context.Context, room return client.RequestSingle[*livekit1.Room](ctx, c.client, "UpdateRoomMetadata", []string{string(room)}, req, opts...) } +func (c *roomClient[RoomTopicType]) ListParticipants(ctx context.Context, room RoomTopicType, req *livekit6.ListParticipantsRequest, opts ...psrpc.RequestOption) (*livekit6.ListParticipantsResponse, error) { + return client.RequestSingle[*livekit6.ListParticipantsResponse](ctx, c.client, "ListParticipants", []string{string(room)}, req, opts...) +} + +func (c *roomClient[RoomTopicType]) GetParticipant(ctx context.Context, room RoomTopicType, req *livekit6.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit6.ParticipantInfo, error) { + return client.RequestSingle[*livekit6.ParticipantInfo](ctx, c.client, "GetParticipant", []string{string(room)}, req, opts...) +} + func (s *roomClient[RoomTopicType]) Close() { s.client.Close() } @@ -133,6 +155,8 @@ func NewRoomServer[RoomTopicType ~string](svc RoomServerImpl, bus psrpc.MessageB sd.RegisterMethod("DeleteRoom", false, false, true, true) sd.RegisterMethod("SendData", false, false, true, true) sd.RegisterMethod("UpdateRoomMetadata", false, false, true, true) + sd.RegisterMethod("ListParticipants", false, false, true, true) + sd.RegisterMethod("GetParticipant", false, false, true, true) return &roomServer[RoomTopicType]{ svc: svc, rpc: s, @@ -163,11 +187,29 @@ func (s *roomServer[RoomTopicType]) DeregisterUpdateRoomMetadataTopic(room RoomT s.rpc.DeregisterHandler("UpdateRoomMetadata", []string{string(room)}) } +func (s *roomServer[RoomTopicType]) RegisterListParticipantsTopic(room RoomTopicType) error { + return server.RegisterHandler(s.rpc, "ListParticipants", []string{string(room)}, s.svc.ListParticipants, nil) +} + +func (s *roomServer[RoomTopicType]) DeregisterListParticipantsTopic(room RoomTopicType) { + s.rpc.DeregisterHandler("ListParticipants", []string{string(room)}) +} + +func (s *roomServer[RoomTopicType]) RegisterGetParticipantTopic(room RoomTopicType) error { + return server.RegisterHandler(s.rpc, "GetParticipant", []string{string(room)}, s.svc.GetParticipant, nil) +} + +func (s *roomServer[RoomTopicType]) DeregisterGetParticipantTopic(room RoomTopicType) { + s.rpc.DeregisterHandler("GetParticipant", []string{string(room)}) +} + func (s *roomServer[RoomTopicType]) allRoomTopicRegisterers() server.RegistererSlice { return server.RegistererSlice{ server.NewRegisterer(s.RegisterDeleteRoomTopic, s.DeregisterDeleteRoomTopic), server.NewRegisterer(s.RegisterSendDataTopic, s.DeregisterSendDataTopic), server.NewRegisterer(s.RegisterUpdateRoomMetadataTopic, s.DeregisterUpdateRoomMetadataTopic), + server.NewRegisterer(s.RegisterListParticipantsTopic, s.DeregisterListParticipantsTopic), + server.NewRegisterer(s.RegisterGetParticipantTopic, s.DeregisterGetParticipantTopic), } } @@ -205,6 +247,14 @@ func (UnimplementedRoomServer) UpdateRoomMetadata(context.Context, *livekit6.Upd return nil, psrpc.ErrUnimplemented } +func (UnimplementedRoomServer) ListParticipants(context.Context, *livekit6.ListParticipantsRequest) (*livekit6.ListParticipantsResponse, error) { + return nil, psrpc.ErrUnimplemented +} + +func (UnimplementedRoomServer) GetParticipant(context.Context, *livekit6.RoomParticipantIdentity) (*livekit6.ParticipantInfo, error) { + return nil, psrpc.ErrUnimplemented +} + var psrpcFileDescriptor7 = []byte{ // 230 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2b, 0x2a, 0x48, 0xd6, diff --git a/rpc/rpcfakes/fake_typed_room_client.go b/rpc/rpcfakes/fake_typed_room_client.go index 2539080b4..c67cf8ec2 100644 --- a/rpc/rpcfakes/fake_typed_room_client.go +++ b/rpc/rpcfakes/fake_typed_room_client.go @@ -63,6 +63,38 @@ type FakeTypedRoomClient struct { result1 *livekit.Room result2 error } + ListParticipantsStub func(context.Context, rpc.RoomTopic, *livekit.ListParticipantsRequest, ...psrpc.RequestOption) (*livekit.ListParticipantsResponse, error) + listParticipantsMutex sync.RWMutex + listParticipantsArgsForCall []struct { + arg1 context.Context + arg2 rpc.RoomTopic + arg3 *livekit.ListParticipantsRequest + arg4 []psrpc.RequestOption + } + listParticipantsReturns struct { + result1 *livekit.ListParticipantsResponse + result2 error + } + listParticipantsReturnsOnCall map[int]struct { + result1 *livekit.ListParticipantsResponse + result2 error + } + GetParticipantStub func(context.Context, rpc.RoomTopic, *livekit.RoomParticipantIdentity, ...psrpc.RequestOption) (*livekit.ParticipantInfo, error) + getParticipantMutex sync.RWMutex + getParticipantArgsForCall []struct { + arg1 context.Context + arg2 rpc.RoomTopic + arg3 *livekit.RoomParticipantIdentity + arg4 []psrpc.RequestOption + } + getParticipantReturns struct { + result1 *livekit.ParticipantInfo + result2 error + } + getParticipantReturnsOnCall map[int]struct { + result1 *livekit.ParticipantInfo + result2 error + } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } @@ -292,6 +324,140 @@ func (fake *FakeTypedRoomClient) UpdateRoomMetadataReturnsOnCall(i int, result1 }{result1, result2} } +func (fake *FakeTypedRoomClient) ListParticipants(arg1 context.Context, arg2 rpc.RoomTopic, arg3 *livekit.ListParticipantsRequest, arg4 ...psrpc.RequestOption) (*livekit.ListParticipantsResponse, error) { + fake.listParticipantsMutex.Lock() + ret, specificReturn := fake.listParticipantsReturnsOnCall[len(fake.listParticipantsArgsForCall)] + fake.listParticipantsArgsForCall = append(fake.listParticipantsArgsForCall, struct { + arg1 context.Context + arg2 rpc.RoomTopic + arg3 *livekit.ListParticipantsRequest + arg4 []psrpc.RequestOption + }{arg1, arg2, arg3, arg4}) + stub := fake.ListParticipantsStub + fakeReturns := fake.listParticipantsReturns + fake.recordInvocation("ListParticipants", []interface{}{arg1, arg2, arg3, arg4}) + fake.listParticipantsMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3, arg4...) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeTypedRoomClient) ListParticipantsCallCount() int { + fake.listParticipantsMutex.RLock() + defer fake.listParticipantsMutex.RUnlock() + return len(fake.listParticipantsArgsForCall) +} + +func (fake *FakeTypedRoomClient) ListParticipantsCalls(stub func(context.Context, rpc.RoomTopic, *livekit.ListParticipantsRequest, ...psrpc.RequestOption) (*livekit.ListParticipantsResponse, error)) { + fake.listParticipantsMutex.Lock() + defer fake.listParticipantsMutex.Unlock() + fake.ListParticipantsStub = stub +} + +func (fake *FakeTypedRoomClient) ListParticipantsArgsForCall(i int) (context.Context, rpc.RoomTopic, *livekit.ListParticipantsRequest, []psrpc.RequestOption) { + fake.listParticipantsMutex.RLock() + defer fake.listParticipantsMutex.RUnlock() + argsForCall := fake.listParticipantsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 +} + +func (fake *FakeTypedRoomClient) ListParticipantsReturns(result1 *livekit.ListParticipantsResponse, result2 error) { + fake.listParticipantsMutex.Lock() + defer fake.listParticipantsMutex.Unlock() + fake.ListParticipantsStub = nil + fake.listParticipantsReturns = struct { + result1 *livekit.ListParticipantsResponse + result2 error + }{result1, result2} +} + +func (fake *FakeTypedRoomClient) ListParticipantsReturnsOnCall(i int, result1 *livekit.ListParticipantsResponse, result2 error) { + fake.listParticipantsMutex.Lock() + defer fake.listParticipantsMutex.Unlock() + fake.ListParticipantsStub = nil + if fake.listParticipantsReturnsOnCall == nil { + fake.listParticipantsReturnsOnCall = make(map[int]struct { + result1 *livekit.ListParticipantsResponse + result2 error + }) + } + fake.listParticipantsReturnsOnCall[i] = struct { + result1 *livekit.ListParticipantsResponse + result2 error + }{result1, result2} +} + +func (fake *FakeTypedRoomClient) GetParticipant(arg1 context.Context, arg2 rpc.RoomTopic, arg3 *livekit.RoomParticipantIdentity, arg4 ...psrpc.RequestOption) (*livekit.ParticipantInfo, error) { + fake.getParticipantMutex.Lock() + ret, specificReturn := fake.getParticipantReturnsOnCall[len(fake.getParticipantArgsForCall)] + fake.getParticipantArgsForCall = append(fake.getParticipantArgsForCall, struct { + arg1 context.Context + arg2 rpc.RoomTopic + arg3 *livekit.RoomParticipantIdentity + arg4 []psrpc.RequestOption + }{arg1, arg2, arg3, arg4}) + stub := fake.GetParticipantStub + fakeReturns := fake.getParticipantReturns + fake.recordInvocation("GetParticipant", []interface{}{arg1, arg2, arg3, arg4}) + fake.getParticipantMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3, arg4...) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeTypedRoomClient) GetParticipantCallCount() int { + fake.getParticipantMutex.RLock() + defer fake.getParticipantMutex.RUnlock() + return len(fake.getParticipantArgsForCall) +} + +func (fake *FakeTypedRoomClient) GetParticipantCalls(stub func(context.Context, rpc.RoomTopic, *livekit.RoomParticipantIdentity, ...psrpc.RequestOption) (*livekit.ParticipantInfo, error)) { + fake.getParticipantMutex.Lock() + defer fake.getParticipantMutex.Unlock() + fake.GetParticipantStub = stub +} + +func (fake *FakeTypedRoomClient) GetParticipantArgsForCall(i int) (context.Context, rpc.RoomTopic, *livekit.RoomParticipantIdentity, []psrpc.RequestOption) { + fake.getParticipantMutex.RLock() + defer fake.getParticipantMutex.RUnlock() + argsForCall := fake.getParticipantArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 +} + +func (fake *FakeTypedRoomClient) GetParticipantReturns(result1 *livekit.ParticipantInfo, result2 error) { + fake.getParticipantMutex.Lock() + defer fake.getParticipantMutex.Unlock() + fake.GetParticipantStub = nil + fake.getParticipantReturns = struct { + result1 *livekit.ParticipantInfo + result2 error + }{result1, result2} +} + +func (fake *FakeTypedRoomClient) GetParticipantReturnsOnCall(i int, result1 *livekit.ParticipantInfo, result2 error) { + fake.getParticipantMutex.Lock() + defer fake.getParticipantMutex.Unlock() + fake.GetParticipantStub = nil + if fake.getParticipantReturnsOnCall == nil { + fake.getParticipantReturnsOnCall = make(map[int]struct { + result1 *livekit.ParticipantInfo + result2 error + }) + } + fake.getParticipantReturnsOnCall[i] = struct { + result1 *livekit.ParticipantInfo + result2 error + }{result1, result2} +} + func (fake *FakeTypedRoomClient) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() @@ -303,6 +469,10 @@ func (fake *FakeTypedRoomClient) Invocations() map[string][][]interface{} { defer fake.sendDataMutex.RUnlock() fake.updateRoomMetadataMutex.RLock() defer fake.updateRoomMetadataMutex.RUnlock() + fake.listParticipantsMutex.RLock() + defer fake.listParticipantsMutex.RUnlock() + fake.getParticipantMutex.RLock() + defer fake.getParticipantMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value