github.com/livekit/protocol@v1.39.3/rpc/participant.psrpc.go (about) 1 // Code generated by protoc-gen-psrpc v0.6.0, DO NOT EDIT. 2 // source: rpc/participant.proto 3 4 package rpc 5 6 import ( 7 "context" 8 9 "github.com/livekit/psrpc" 10 "github.com/livekit/psrpc/pkg/client" 11 "github.com/livekit/psrpc/pkg/info" 12 "github.com/livekit/psrpc/pkg/rand" 13 "github.com/livekit/psrpc/pkg/server" 14 "github.com/livekit/psrpc/version" 15 ) 16 import livekit1 "github.com/livekit/protocol/livekit" 17 import livekit6 "github.com/livekit/protocol/livekit" 18 19 var _ = version.PsrpcVersion_0_6 20 21 // ============================ 22 // Participant Client Interface 23 // ============================ 24 25 type ParticipantClient[ParticipantTopicType ~string] interface { 26 RemoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit6.RemoveParticipantResponse, error) 27 28 MutePublishedTrack(ctx context.Context, participant ParticipantTopicType, req *livekit6.MuteRoomTrackRequest, opts ...psrpc.RequestOption) (*livekit6.MuteRoomTrackResponse, error) 29 30 UpdateParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateParticipantRequest, opts ...psrpc.RequestOption) (*livekit1.ParticipantInfo, error) 31 32 UpdateSubscriptions(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateSubscriptionsRequest, opts ...psrpc.RequestOption) (*livekit6.UpdateSubscriptionsResponse, error) 33 34 ForwardParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.ForwardParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.ForwardParticipantResponse, error) 35 36 MoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.MoveParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.MoveParticipantResponse, error) 37 38 // Close immediately, without waiting for pending RPCs 39 Close() 40 } 41 42 // ================================ 43 // Participant ServerImpl Interface 44 // ================================ 45 46 type ParticipantServerImpl interface { 47 RemoveParticipant(context.Context, *livekit6.RoomParticipantIdentity) (*livekit6.RemoveParticipantResponse, error) 48 49 MutePublishedTrack(context.Context, *livekit6.MuteRoomTrackRequest) (*livekit6.MuteRoomTrackResponse, error) 50 51 UpdateParticipant(context.Context, *livekit6.UpdateParticipantRequest) (*livekit1.ParticipantInfo, error) 52 53 UpdateSubscriptions(context.Context, *livekit6.UpdateSubscriptionsRequest) (*livekit6.UpdateSubscriptionsResponse, error) 54 55 ForwardParticipant(context.Context, *livekit6.ForwardParticipantRequest) (*livekit6.ForwardParticipantResponse, error) 56 57 MoveParticipant(context.Context, *livekit6.MoveParticipantRequest) (*livekit6.MoveParticipantResponse, error) 58 } 59 60 // ============================ 61 // Participant Server Interface 62 // ============================ 63 64 type ParticipantServer[ParticipantTopicType ~string] interface { 65 RegisterRemoveParticipantTopic(participant ParticipantTopicType) error 66 DeregisterRemoveParticipantTopic(participant ParticipantTopicType) 67 RegisterMutePublishedTrackTopic(participant ParticipantTopicType) error 68 DeregisterMutePublishedTrackTopic(participant ParticipantTopicType) 69 RegisterUpdateParticipantTopic(participant ParticipantTopicType) error 70 DeregisterUpdateParticipantTopic(participant ParticipantTopicType) 71 RegisterUpdateSubscriptionsTopic(participant ParticipantTopicType) error 72 DeregisterUpdateSubscriptionsTopic(participant ParticipantTopicType) 73 RegisterForwardParticipantTopic(participant ParticipantTopicType) error 74 DeregisterForwardParticipantTopic(participant ParticipantTopicType) 75 RegisterMoveParticipantTopic(participant ParticipantTopicType) error 76 DeregisterMoveParticipantTopic(participant ParticipantTopicType) 77 RegisterAllParticipantTopics(participant ParticipantTopicType) error 78 DeregisterAllParticipantTopics(participant ParticipantTopicType) 79 80 // Close and wait for pending RPCs to complete 81 Shutdown() 82 83 // Close immediately, without waiting for pending RPCs 84 Kill() 85 } 86 87 // ================== 88 // Participant Client 89 // ================== 90 91 type participantClient[ParticipantTopicType ~string] struct { 92 client *client.RPCClient 93 } 94 95 // NewParticipantClient creates a psrpc client that implements the ParticipantClient interface. 96 func NewParticipantClient[ParticipantTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (ParticipantClient[ParticipantTopicType], error) { 97 sd := &info.ServiceDefinition{ 98 Name: "Participant", 99 ID: rand.NewClientID(), 100 } 101 102 sd.RegisterMethod("RemoveParticipant", false, false, true, true) 103 sd.RegisterMethod("MutePublishedTrack", false, false, true, true) 104 sd.RegisterMethod("UpdateParticipant", false, false, true, true) 105 sd.RegisterMethod("UpdateSubscriptions", false, false, true, true) 106 sd.RegisterMethod("ForwardParticipant", false, false, true, true) 107 sd.RegisterMethod("MoveParticipant", false, false, true, true) 108 109 rpcClient, err := client.NewRPCClient(sd, bus, opts...) 110 if err != nil { 111 return nil, err 112 } 113 114 return &participantClient[ParticipantTopicType]{ 115 client: rpcClient, 116 }, nil 117 } 118 119 func (c *participantClient[ParticipantTopicType]) RemoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit6.RemoveParticipantResponse, error) { 120 return client.RequestSingle[*livekit6.RemoveParticipantResponse](ctx, c.client, "RemoveParticipant", []string{string(participant)}, req, opts...) 121 } 122 123 func (c *participantClient[ParticipantTopicType]) MutePublishedTrack(ctx context.Context, participant ParticipantTopicType, req *livekit6.MuteRoomTrackRequest, opts ...psrpc.RequestOption) (*livekit6.MuteRoomTrackResponse, error) { 124 return client.RequestSingle[*livekit6.MuteRoomTrackResponse](ctx, c.client, "MutePublishedTrack", []string{string(participant)}, req, opts...) 125 } 126 127 func (c *participantClient[ParticipantTopicType]) UpdateParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateParticipantRequest, opts ...psrpc.RequestOption) (*livekit1.ParticipantInfo, error) { 128 return client.RequestSingle[*livekit1.ParticipantInfo](ctx, c.client, "UpdateParticipant", []string{string(participant)}, req, opts...) 129 } 130 131 func (c *participantClient[ParticipantTopicType]) UpdateSubscriptions(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateSubscriptionsRequest, opts ...psrpc.RequestOption) (*livekit6.UpdateSubscriptionsResponse, error) { 132 return client.RequestSingle[*livekit6.UpdateSubscriptionsResponse](ctx, c.client, "UpdateSubscriptions", []string{string(participant)}, req, opts...) 133 } 134 135 func (c *participantClient[ParticipantTopicType]) ForwardParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.ForwardParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.ForwardParticipantResponse, error) { 136 return client.RequestSingle[*livekit6.ForwardParticipantResponse](ctx, c.client, "ForwardParticipant", []string{string(participant)}, req, opts...) 137 } 138 139 func (c *participantClient[ParticipantTopicType]) MoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.MoveParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.MoveParticipantResponse, error) { 140 return client.RequestSingle[*livekit6.MoveParticipantResponse](ctx, c.client, "MoveParticipant", []string{string(participant)}, req, opts...) 141 } 142 143 func (s *participantClient[ParticipantTopicType]) Close() { 144 s.client.Close() 145 } 146 147 // ================== 148 // Participant Server 149 // ================== 150 151 type participantServer[ParticipantTopicType ~string] struct { 152 svc ParticipantServerImpl 153 rpc *server.RPCServer 154 } 155 156 // NewParticipantServer builds a RPCServer that will route requests 157 // to the corresponding method in the provided svc implementation. 158 func NewParticipantServer[ParticipantTopicType ~string](svc ParticipantServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (ParticipantServer[ParticipantTopicType], error) { 159 sd := &info.ServiceDefinition{ 160 Name: "Participant", 161 ID: rand.NewServerID(), 162 } 163 164 s := server.NewRPCServer(sd, bus, opts...) 165 166 sd.RegisterMethod("RemoveParticipant", false, false, true, true) 167 sd.RegisterMethod("MutePublishedTrack", false, false, true, true) 168 sd.RegisterMethod("UpdateParticipant", false, false, true, true) 169 sd.RegisterMethod("UpdateSubscriptions", false, false, true, true) 170 sd.RegisterMethod("ForwardParticipant", false, false, true, true) 171 sd.RegisterMethod("MoveParticipant", false, false, true, true) 172 return &participantServer[ParticipantTopicType]{ 173 svc: svc, 174 rpc: s, 175 }, nil 176 } 177 178 func (s *participantServer[ParticipantTopicType]) RegisterRemoveParticipantTopic(participant ParticipantTopicType) error { 179 return server.RegisterHandler(s.rpc, "RemoveParticipant", []string{string(participant)}, s.svc.RemoveParticipant, nil) 180 } 181 182 func (s *participantServer[ParticipantTopicType]) DeregisterRemoveParticipantTopic(participant ParticipantTopicType) { 183 s.rpc.DeregisterHandler("RemoveParticipant", []string{string(participant)}) 184 } 185 186 func (s *participantServer[ParticipantTopicType]) RegisterMutePublishedTrackTopic(participant ParticipantTopicType) error { 187 return server.RegisterHandler(s.rpc, "MutePublishedTrack", []string{string(participant)}, s.svc.MutePublishedTrack, nil) 188 } 189 190 func (s *participantServer[ParticipantTopicType]) DeregisterMutePublishedTrackTopic(participant ParticipantTopicType) { 191 s.rpc.DeregisterHandler("MutePublishedTrack", []string{string(participant)}) 192 } 193 194 func (s *participantServer[ParticipantTopicType]) RegisterUpdateParticipantTopic(participant ParticipantTopicType) error { 195 return server.RegisterHandler(s.rpc, "UpdateParticipant", []string{string(participant)}, s.svc.UpdateParticipant, nil) 196 } 197 198 func (s *participantServer[ParticipantTopicType]) DeregisterUpdateParticipantTopic(participant ParticipantTopicType) { 199 s.rpc.DeregisterHandler("UpdateParticipant", []string{string(participant)}) 200 } 201 202 func (s *participantServer[ParticipantTopicType]) RegisterUpdateSubscriptionsTopic(participant ParticipantTopicType) error { 203 return server.RegisterHandler(s.rpc, "UpdateSubscriptions", []string{string(participant)}, s.svc.UpdateSubscriptions, nil) 204 } 205 206 func (s *participantServer[ParticipantTopicType]) DeregisterUpdateSubscriptionsTopic(participant ParticipantTopicType) { 207 s.rpc.DeregisterHandler("UpdateSubscriptions", []string{string(participant)}) 208 } 209 210 func (s *participantServer[ParticipantTopicType]) RegisterForwardParticipantTopic(participant ParticipantTopicType) error { 211 return server.RegisterHandler(s.rpc, "ForwardParticipant", []string{string(participant)}, s.svc.ForwardParticipant, nil) 212 } 213 214 func (s *participantServer[ParticipantTopicType]) DeregisterForwardParticipantTopic(participant ParticipantTopicType) { 215 s.rpc.DeregisterHandler("ForwardParticipant", []string{string(participant)}) 216 } 217 218 func (s *participantServer[ParticipantTopicType]) RegisterMoveParticipantTopic(participant ParticipantTopicType) error { 219 return server.RegisterHandler(s.rpc, "MoveParticipant", []string{string(participant)}, s.svc.MoveParticipant, nil) 220 } 221 222 func (s *participantServer[ParticipantTopicType]) DeregisterMoveParticipantTopic(participant ParticipantTopicType) { 223 s.rpc.DeregisterHandler("MoveParticipant", []string{string(participant)}) 224 } 225 226 func (s *participantServer[ParticipantTopicType]) allParticipantTopicRegisterers() server.RegistererSlice { 227 return server.RegistererSlice{ 228 server.NewRegisterer(s.RegisterRemoveParticipantTopic, s.DeregisterRemoveParticipantTopic), 229 server.NewRegisterer(s.RegisterMutePublishedTrackTopic, s.DeregisterMutePublishedTrackTopic), 230 server.NewRegisterer(s.RegisterUpdateParticipantTopic, s.DeregisterUpdateParticipantTopic), 231 server.NewRegisterer(s.RegisterUpdateSubscriptionsTopic, s.DeregisterUpdateSubscriptionsTopic), 232 server.NewRegisterer(s.RegisterForwardParticipantTopic, s.DeregisterForwardParticipantTopic), 233 server.NewRegisterer(s.RegisterMoveParticipantTopic, s.DeregisterMoveParticipantTopic), 234 } 235 } 236 237 func (s *participantServer[ParticipantTopicType]) RegisterAllParticipantTopics(participant ParticipantTopicType) error { 238 return s.allParticipantTopicRegisterers().Register(participant) 239 } 240 241 func (s *participantServer[ParticipantTopicType]) DeregisterAllParticipantTopics(participant ParticipantTopicType) { 242 s.allParticipantTopicRegisterers().Deregister(participant) 243 } 244 245 func (s *participantServer[ParticipantTopicType]) Shutdown() { 246 s.rpc.Close(false) 247 } 248 249 func (s *participantServer[ParticipantTopicType]) Kill() { 250 s.rpc.Close(true) 251 } 252 253 var psrpcFileDescriptor6 = []byte{ 254 // 337 bytes of a gzipped FileDescriptorProto 255 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4f, 0x4b, 0xfb, 0x40, 256 0x10, 0x25, 0xfc, 0xa0, 0x87, 0x2d, 0x3f, 0xb4, 0xab, 0x42, 0x09, 0x6a, 0xff, 0x9e, 0x13, 0xd0, 257 0x6f, 0xe0, 0x41, 0xf0, 0x50, 0x28, 0x51, 0x2f, 0x5e, 0x24, 0xd9, 0xac, 0x76, 0x69, 0x92, 0x59, 258 0x77, 0x27, 0x95, 0x7a, 0xf1, 0x20, 0x08, 0x82, 0x9f, 0xc6, 0x4f, 0x28, 0x4d, 0x9a, 0x64, 0x9b, 259 0xd2, 0x62, 0x8e, 0xfb, 0xde, 0xdb, 0xf7, 0x66, 0x67, 0x66, 0xc9, 0x89, 0x92, 0xcc, 0x95, 0xbe, 260 0x42, 0xc1, 0x84, 0xf4, 0x13, 0x74, 0xa4, 0x02, 0x04, 0xfa, 0x4f, 0x49, 0x66, 0xff, 0x07, 0x89, 261 0x02, 0x12, 0x9d, 0x63, 0xf6, 0x71, 0x24, 0x16, 0x7c, 0x2e, 0xf0, 0x31, 0x86, 0x90, 0x47, 0x05, 262 0x4a, 0x0b, 0x54, 0x01, 0xc4, 0x39, 0x76, 0xf1, 0xdd, 0x22, 0xed, 0x69, 0xe5, 0x49, 0xdf, 0x49, 263 0xc7, 0xe3, 0x31, 0x2c, 0xb8, 0x09, 0xf6, 0x9d, 0xf5, 0x4d, 0xc7, 0x03, 0x88, 0x0d, 0xe6, 0x26, 264 0xe4, 0x09, 0x0a, 0x5c, 0xda, 0xc3, 0x4a, 0x51, 0xbf, 0xed, 0x71, 0x2d, 0x21, 0xd1, 0x7c, 0x38, 265 0xfe, 0xf9, 0xb2, 0xfa, 0x87, 0x96, 0x7d, 0x4a, 0xda, 0xc6, 0x2b, 0xa8, 0x79, 0xe8, 0x5a, 0x74, 266 0x49, 0xe8, 0x24, 0x45, 0x3e, 0x4d, 0x83, 0x48, 0xe8, 0x19, 0x0f, 0xef, 0x94, 0xcf, 0xe6, 0xf4, 267 0xac, 0xf4, 0x5f, 0x91, 0xab, 0x2a, 0x32, 0xdc, 0xe3, 0x2f, 0x29, 0xd7, 0x68, 0x9f, 0xef, 0xa2, 268 0x1b, 0x45, 0x2f, 0x48, 0xe7, 0x5e, 0x86, 0x3e, 0x6e, 0xbc, 0x7d, 0x50, 0x5a, 0x6f, 0x71, 0x45, 269 0x7a, 0xb7, 0x94, 0x98, 0xad, 0x49, 0x9e, 0xe0, 0x8f, 0xb9, 0x9f, 0x16, 0x39, 0xca, 0xcd, 0x6f, 270 0xd3, 0x40, 0x33, 0x25, 0xf2, 0x59, 0xd2, 0x51, 0x2d, 0x7a, 0x83, 0x2d, 0xc2, 0xc7, 0xfb, 0x45, 271 0x8d, 0x1a, 0xf0, 0x61, 0x11, 0x7a, 0x0d, 0xea, 0xd5, 0x57, 0xa1, 0xd9, 0x82, 0x6a, 0xb8, 0xdb, 272 0x64, 0x51, 0xc6, 0x68, 0xaf, 0xa6, 0x51, 0x15, 0x6f, 0xe4, 0x60, 0x52, 0x5b, 0xc0, 0x5e, 0x35, 273 0xdf, 0xfa, 0x72, 0xe5, 0xf1, 0xfd, 0xdd, 0x82, 0x26, 0xd9, 0x57, 0x83, 0x87, 0xde, 0xb3, 0xc0, 274 0x59, 0x1a, 0x38, 0x0c, 0x62, 0x77, 0xed, 0xe9, 0x66, 0x5f, 0x85, 0x41, 0xe4, 0x2a, 0xc9, 0x82, 275 0x56, 0x76, 0xba, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x30, 0x94, 0x6b, 0x3a, 0x8f, 0x03, 0x00, 276 0x00, 277 }