github.com/livekit/protocol@v1.16.1-0.20240517185851-47e4c6bba773/rpc/participant.psrpc.go (about) 1 // Code generated by protoc-gen-psrpc v0.5.1, 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 livekit "github.com/livekit/protocol/livekit" 17 import livekit4 "github.com/livekit/protocol/livekit" 18 19 var _ = version.PsrpcVersion_0_5 20 21 // ============================ 22 // Participant Client Interface 23 // ============================ 24 25 type ParticipantClient[ParticipantTopicType ~string] interface { 26 RemoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit4.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit4.RemoveParticipantResponse, error) 27 28 MutePublishedTrack(ctx context.Context, participant ParticipantTopicType, req *livekit4.MuteRoomTrackRequest, opts ...psrpc.RequestOption) (*livekit4.MuteRoomTrackResponse, error) 29 30 UpdateParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit4.UpdateParticipantRequest, opts ...psrpc.RequestOption) (*livekit.ParticipantInfo, error) 31 32 UpdateSubscriptions(ctx context.Context, participant ParticipantTopicType, req *livekit4.UpdateSubscriptionsRequest, opts ...psrpc.RequestOption) (*livekit4.UpdateSubscriptionsResponse, error) 33 } 34 35 // ================================ 36 // Participant ServerImpl Interface 37 // ================================ 38 39 type ParticipantServerImpl interface { 40 RemoveParticipant(context.Context, *livekit4.RoomParticipantIdentity) (*livekit4.RemoveParticipantResponse, error) 41 42 MutePublishedTrack(context.Context, *livekit4.MuteRoomTrackRequest) (*livekit4.MuteRoomTrackResponse, error) 43 44 UpdateParticipant(context.Context, *livekit4.UpdateParticipantRequest) (*livekit.ParticipantInfo, error) 45 46 UpdateSubscriptions(context.Context, *livekit4.UpdateSubscriptionsRequest) (*livekit4.UpdateSubscriptionsResponse, error) 47 } 48 49 // ============================ 50 // Participant Server Interface 51 // ============================ 52 53 type ParticipantServer[ParticipantTopicType ~string] interface { 54 RegisterRemoveParticipantTopic(participant ParticipantTopicType) error 55 DeregisterRemoveParticipantTopic(participant ParticipantTopicType) 56 RegisterMutePublishedTrackTopic(participant ParticipantTopicType) error 57 DeregisterMutePublishedTrackTopic(participant ParticipantTopicType) 58 RegisterUpdateParticipantTopic(participant ParticipantTopicType) error 59 DeregisterUpdateParticipantTopic(participant ParticipantTopicType) 60 RegisterUpdateSubscriptionsTopic(participant ParticipantTopicType) error 61 DeregisterUpdateSubscriptionsTopic(participant ParticipantTopicType) 62 RegisterAllParticipantTopics(participant ParticipantTopicType) error 63 DeregisterAllParticipantTopics(participant ParticipantTopicType) 64 65 // Close and wait for pending RPCs to complete 66 Shutdown() 67 68 // Close immediately, without waiting for pending RPCs 69 Kill() 70 } 71 72 // ================== 73 // Participant Client 74 // ================== 75 76 type participantClient[ParticipantTopicType ~string] struct { 77 client *client.RPCClient 78 } 79 80 // NewParticipantClient creates a psrpc client that implements the ParticipantClient interface. 81 func NewParticipantClient[ParticipantTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (ParticipantClient[ParticipantTopicType], error) { 82 sd := &info.ServiceDefinition{ 83 Name: "Participant", 84 ID: rand.NewClientID(), 85 } 86 87 sd.RegisterMethod("RemoveParticipant", false, false, true, true) 88 sd.RegisterMethod("MutePublishedTrack", false, false, true, true) 89 sd.RegisterMethod("UpdateParticipant", false, false, true, true) 90 sd.RegisterMethod("UpdateSubscriptions", false, false, true, true) 91 92 rpcClient, err := client.NewRPCClient(sd, bus, opts...) 93 if err != nil { 94 return nil, err 95 } 96 97 return &participantClient[ParticipantTopicType]{ 98 client: rpcClient, 99 }, nil 100 } 101 102 func (c *participantClient[ParticipantTopicType]) RemoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit4.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit4.RemoveParticipantResponse, error) { 103 return client.RequestSingle[*livekit4.RemoveParticipantResponse](ctx, c.client, "RemoveParticipant", []string{string(participant)}, req, opts...) 104 } 105 106 func (c *participantClient[ParticipantTopicType]) MutePublishedTrack(ctx context.Context, participant ParticipantTopicType, req *livekit4.MuteRoomTrackRequest, opts ...psrpc.RequestOption) (*livekit4.MuteRoomTrackResponse, error) { 107 return client.RequestSingle[*livekit4.MuteRoomTrackResponse](ctx, c.client, "MutePublishedTrack", []string{string(participant)}, req, opts...) 108 } 109 110 func (c *participantClient[ParticipantTopicType]) UpdateParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit4.UpdateParticipantRequest, opts ...psrpc.RequestOption) (*livekit.ParticipantInfo, error) { 111 return client.RequestSingle[*livekit.ParticipantInfo](ctx, c.client, "UpdateParticipant", []string{string(participant)}, req, opts...) 112 } 113 114 func (c *participantClient[ParticipantTopicType]) UpdateSubscriptions(ctx context.Context, participant ParticipantTopicType, req *livekit4.UpdateSubscriptionsRequest, opts ...psrpc.RequestOption) (*livekit4.UpdateSubscriptionsResponse, error) { 115 return client.RequestSingle[*livekit4.UpdateSubscriptionsResponse](ctx, c.client, "UpdateSubscriptions", []string{string(participant)}, req, opts...) 116 } 117 118 // ================== 119 // Participant Server 120 // ================== 121 122 type participantServer[ParticipantTopicType ~string] struct { 123 svc ParticipantServerImpl 124 rpc *server.RPCServer 125 } 126 127 // NewParticipantServer builds a RPCServer that will route requests 128 // to the corresponding method in the provided svc implementation. 129 func NewParticipantServer[ParticipantTopicType ~string](svc ParticipantServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (ParticipantServer[ParticipantTopicType], error) { 130 sd := &info.ServiceDefinition{ 131 Name: "Participant", 132 ID: rand.NewServerID(), 133 } 134 135 s := server.NewRPCServer(sd, bus, opts...) 136 137 sd.RegisterMethod("RemoveParticipant", false, false, true, true) 138 sd.RegisterMethod("MutePublishedTrack", false, false, true, true) 139 sd.RegisterMethod("UpdateParticipant", false, false, true, true) 140 sd.RegisterMethod("UpdateSubscriptions", false, false, true, true) 141 return &participantServer[ParticipantTopicType]{ 142 svc: svc, 143 rpc: s, 144 }, nil 145 } 146 147 func (s *participantServer[ParticipantTopicType]) RegisterRemoveParticipantTopic(participant ParticipantTopicType) error { 148 return server.RegisterHandler(s.rpc, "RemoveParticipant", []string{string(participant)}, s.svc.RemoveParticipant, nil) 149 } 150 151 func (s *participantServer[ParticipantTopicType]) DeregisterRemoveParticipantTopic(participant ParticipantTopicType) { 152 s.rpc.DeregisterHandler("RemoveParticipant", []string{string(participant)}) 153 } 154 155 func (s *participantServer[ParticipantTopicType]) RegisterMutePublishedTrackTopic(participant ParticipantTopicType) error { 156 return server.RegisterHandler(s.rpc, "MutePublishedTrack", []string{string(participant)}, s.svc.MutePublishedTrack, nil) 157 } 158 159 func (s *participantServer[ParticipantTopicType]) DeregisterMutePublishedTrackTopic(participant ParticipantTopicType) { 160 s.rpc.DeregisterHandler("MutePublishedTrack", []string{string(participant)}) 161 } 162 163 func (s *participantServer[ParticipantTopicType]) RegisterUpdateParticipantTopic(participant ParticipantTopicType) error { 164 return server.RegisterHandler(s.rpc, "UpdateParticipant", []string{string(participant)}, s.svc.UpdateParticipant, nil) 165 } 166 167 func (s *participantServer[ParticipantTopicType]) DeregisterUpdateParticipantTopic(participant ParticipantTopicType) { 168 s.rpc.DeregisterHandler("UpdateParticipant", []string{string(participant)}) 169 } 170 171 func (s *participantServer[ParticipantTopicType]) RegisterUpdateSubscriptionsTopic(participant ParticipantTopicType) error { 172 return server.RegisterHandler(s.rpc, "UpdateSubscriptions", []string{string(participant)}, s.svc.UpdateSubscriptions, nil) 173 } 174 175 func (s *participantServer[ParticipantTopicType]) DeregisterUpdateSubscriptionsTopic(participant ParticipantTopicType) { 176 s.rpc.DeregisterHandler("UpdateSubscriptions", []string{string(participant)}) 177 } 178 179 func (s *participantServer[ParticipantTopicType]) allParticipantTopicRegisterers() server.RegistererSlice { 180 return server.RegistererSlice{ 181 server.NewRegisterer(s.RegisterRemoveParticipantTopic, s.DeregisterRemoveParticipantTopic), 182 server.NewRegisterer(s.RegisterMutePublishedTrackTopic, s.DeregisterMutePublishedTrackTopic), 183 server.NewRegisterer(s.RegisterUpdateParticipantTopic, s.DeregisterUpdateParticipantTopic), 184 server.NewRegisterer(s.RegisterUpdateSubscriptionsTopic, s.DeregisterUpdateSubscriptionsTopic), 185 } 186 } 187 188 func (s *participantServer[ParticipantTopicType]) RegisterAllParticipantTopics(participant ParticipantTopicType) error { 189 return s.allParticipantTopicRegisterers().Register(participant) 190 } 191 192 func (s *participantServer[ParticipantTopicType]) DeregisterAllParticipantTopics(participant ParticipantTopicType) { 193 s.allParticipantTopicRegisterers().Deregister(participant) 194 } 195 196 func (s *participantServer[ParticipantTopicType]) Shutdown() { 197 s.rpc.Close(false) 198 } 199 200 func (s *participantServer[ParticipantTopicType]) Kill() { 201 s.rpc.Close(true) 202 } 203 204 var psrpcFileDescriptor5 = []byte{ 205 // 293 bytes of a gzipped FileDescriptorProto 206 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xcf, 0x4a, 0xc3, 0x40, 207 0x10, 0xc6, 0x09, 0x8a, 0x87, 0x2d, 0x82, 0x5d, 0x15, 0x4a, 0xf0, 0x4f, 0x5b, 0x7b, 0x4e, 0x40, 208 0xdf, 0xc0, 0x9b, 0x07, 0xa1, 0x44, 0xbd, 0x78, 0x91, 0x64, 0x33, 0xda, 0xa5, 0xc9, 0xce, 0xba, 209 0x3b, 0x5b, 0xe8, 0xc9, 0x9b, 0xa0, 0x8f, 0xe3, 0x13, 0x4a, 0x93, 0x26, 0xdd, 0x56, 0x14, 0x7b, 210 0x9c, 0xdf, 0x37, 0xf3, 0x7d, 0x99, 0xc9, 0xb2, 0x63, 0xa3, 0x45, 0xac, 0x53, 0x43, 0x52, 0x48, 211 0x9d, 0x2a, 0x8a, 0xb4, 0x41, 0x42, 0xbe, 0x63, 0xb4, 0x08, 0xf7, 0x51, 0x93, 0x44, 0x65, 0x6b, 212 0x16, 0x1e, 0x15, 0x72, 0x06, 0x53, 0x49, 0x4f, 0x25, 0xe6, 0x50, 0x34, 0x94, 0x37, 0xd4, 0x20, 213 0x96, 0x35, 0xbb, 0xfc, 0xdc, 0x65, 0x9d, 0xf1, 0xca, 0x93, 0xbf, 0xb1, 0x6e, 0x02, 0x25, 0xce, 214 0xc0, 0x87, 0xfd, 0x68, 0x39, 0x19, 0x25, 0x88, 0xa5, 0xa7, 0xdc, 0xe4, 0xa0, 0x48, 0xd2, 0x3c, 215 0x1c, 0xae, 0x3a, 0x36, 0xa7, 0x13, 0xb0, 0x1a, 0x95, 0x85, 0xe1, 0xe8, 0xeb, 0x23, 0xe8, 0x1f, 216 0x04, 0xe1, 0x09, 0xeb, 0x78, 0x5b, 0x70, 0xbf, 0xe8, 0x05, 0x7c, 0xce, 0xf8, 0xad, 0x23, 0x18, 217 0xbb, 0xac, 0x90, 0x76, 0x02, 0xf9, 0xbd, 0x49, 0xc5, 0x94, 0x9f, 0xb6, 0xfe, 0x0b, 0x71, 0xf1, 218 0x15, 0x15, 0x4f, 0xe0, 0xd5, 0x81, 0xa5, 0xf0, 0xec, 0x37, 0x79, 0xab, 0xe8, 0x19, 0xeb, 0x3e, 219 0xe8, 0x3c, 0xa5, 0xb5, 0xdd, 0x07, 0xad, 0xf5, 0x0f, 0xad, 0x49, 0xef, 0xb5, 0x2d, 0xfe, 0x69, 220 0xd4, 0x33, 0xfe, 0x33, 0xf7, 0x3d, 0x60, 0x87, 0xb5, 0xf9, 0x9d, 0xcb, 0xac, 0x30, 0xb2, 0xfe, 221 0x97, 0xfc, 0x62, 0x23, 0x7a, 0x4d, 0x6d, 0xc2, 0x47, 0x7f, 0x37, 0x6d, 0x73, 0x80, 0xeb, 0xc1, 222 0xe3, 0xf9, 0x8b, 0xa4, 0x89, 0xcb, 0x22, 0x81, 0x65, 0xbc, 0xf4, 0x8d, 0xab, 0x87, 0x22, 0xb0, 223 0x88, 0x8d, 0x16, 0xd9, 0x5e, 0x55, 0x5d, 0x7d, 0x07, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xd9, 0xcf, 224 0x9a, 0x8d, 0x02, 0x00, 0x00, 225 }