feat: server rpc apis (#3904)
* feat: server rpc apis * fix: cleanup * fix: move rpc impl to participant * cleanup * cleanup, psrpc errors * remove TODO comment * update protocol, handle participant disconnect case * add ephemeral participant identity to rpc data packet * fix: panic * chore(deps): bump proto
This commit is contained in:
@@ -825,6 +825,30 @@ func (r *RoomManager) MoveParticipant(ctx context.Context, req *livekit.MovePart
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
||||
func (r *RoomManager) PerformRpc(ctx context.Context, req *livekit.PerformRpcRequest) (*livekit.PerformRpcResponse, error) {
|
||||
room := r.GetRoom(ctx, livekit.RoomName(req.GetRoom()))
|
||||
if room == nil {
|
||||
return nil, ErrRoomNotFound
|
||||
}
|
||||
|
||||
participant := room.GetParticipant(livekit.ParticipantIdentity(req.GetDestinationIdentity()))
|
||||
if participant == nil {
|
||||
return nil, ErrParticipantNotFound
|
||||
}
|
||||
|
||||
resultChan := make(chan string, 1)
|
||||
errorChan := make(chan error, 1)
|
||||
|
||||
participant.PerformRpc(req, resultChan, errorChan)
|
||||
|
||||
select {
|
||||
case result := <-resultChan:
|
||||
return &livekit.PerformRpcResponse{Payload: result}, nil
|
||||
case err := <-errorChan:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RoomManager) DeleteRoom(ctx context.Context, req *livekit.DeleteRoomRequest) (*livekit.DeleteRoomResponse, error) {
|
||||
room := r.GetRoom(ctx, livekit.RoomName(req.Room))
|
||||
if room == nil {
|
||||
|
||||
Reference in New Issue
Block a user