-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathparticipant.psrpc.go
More file actions
333 lines (260 loc) · 17.1 KB
/
Copy pathparticipant.psrpc.go
File metadata and controls
333 lines (260 loc) · 17.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
// Code generated by protoc-gen-psrpc v0.7.3, DO NOT EDIT.
// source: rpc/participant.proto
package rpc
import (
"context"
"github.com/livekit/psrpc"
"github.com/livekit/psrpc/pkg/client"
"github.com/livekit/psrpc/pkg/info"
"github.com/livekit/psrpc/pkg/rand"
"github.com/livekit/psrpc/pkg/server"
"github.com/livekit/psrpc/version"
)
import livekit1 "github.com/livekit/protocol/livekit"
import livekit6 "github.com/livekit/protocol/livekit"
var _ = version.PsrpcVersion_0_7
// ============================
// Participant Client Interface
// ============================
type ParticipantClient[ParticipantTopicType ~string] interface {
RemoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit6.RemoveParticipantResponse, error)
MutePublishedTrack(ctx context.Context, participant ParticipantTopicType, req *livekit6.MuteRoomTrackRequest, opts ...psrpc.RequestOption) (*livekit6.MuteRoomTrackResponse, error)
UpdateParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateParticipantRequest, opts ...psrpc.RequestOption) (*livekit1.ParticipantInfo, error)
UpdateSubscriptions(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateSubscriptionsRequest, opts ...psrpc.RequestOption) (*livekit6.UpdateSubscriptionsResponse, error)
ForwardParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.ForwardParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.ForwardParticipantResponse, error)
MoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.MoveParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.MoveParticipantResponse, error)
PerformRpc(ctx context.Context, participant ParticipantTopicType, req *livekit6.PerformRpcRequest, opts ...psrpc.RequestOption) (*livekit6.PerformRpcResponse, error)
// Close immediately, without waiting for pending RPCs
Close()
}
// ================================
// Participant ServerImpl Interface
// ================================
type ParticipantServerImpl interface {
RemoveParticipant(context.Context, *livekit6.RoomParticipantIdentity) (*livekit6.RemoveParticipantResponse, error)
MutePublishedTrack(context.Context, *livekit6.MuteRoomTrackRequest) (*livekit6.MuteRoomTrackResponse, error)
UpdateParticipant(context.Context, *livekit6.UpdateParticipantRequest) (*livekit1.ParticipantInfo, error)
UpdateSubscriptions(context.Context, *livekit6.UpdateSubscriptionsRequest) (*livekit6.UpdateSubscriptionsResponse, error)
ForwardParticipant(context.Context, *livekit6.ForwardParticipantRequest) (*livekit6.ForwardParticipantResponse, error)
MoveParticipant(context.Context, *livekit6.MoveParticipantRequest) (*livekit6.MoveParticipantResponse, error)
PerformRpc(context.Context, *livekit6.PerformRpcRequest) (*livekit6.PerformRpcResponse, error)
}
// ============================
// Participant Server Interface
// ============================
type ParticipantServer[ParticipantTopicType ~string] interface {
RegisterRemoveParticipantTopic(participant ParticipantTopicType) error
DeregisterRemoveParticipantTopic(participant ParticipantTopicType)
RegisterMutePublishedTrackTopic(participant ParticipantTopicType) error
DeregisterMutePublishedTrackTopic(participant ParticipantTopicType)
RegisterUpdateParticipantTopic(participant ParticipantTopicType) error
DeregisterUpdateParticipantTopic(participant ParticipantTopicType)
RegisterUpdateSubscriptionsTopic(participant ParticipantTopicType) error
DeregisterUpdateSubscriptionsTopic(participant ParticipantTopicType)
RegisterForwardParticipantTopic(participant ParticipantTopicType) error
DeregisterForwardParticipantTopic(participant ParticipantTopicType)
RegisterMoveParticipantTopic(participant ParticipantTopicType) error
DeregisterMoveParticipantTopic(participant ParticipantTopicType)
RegisterPerformRpcTopic(participant ParticipantTopicType) error
DeregisterPerformRpcTopic(participant ParticipantTopicType)
RegisterAllParticipantTopics(participant ParticipantTopicType) error
DeregisterAllParticipantTopics(participant ParticipantTopicType)
// Close and wait for pending RPCs to complete
Shutdown()
// Close immediately, without waiting for pending RPCs
Kill()
}
// ==================
// Participant Client
// ==================
type participantClient[ParticipantTopicType ~string] struct {
client *client.RPCClient
}
// NewParticipantClient creates a psrpc client that implements the ParticipantClient interface.
func NewParticipantClient[ParticipantTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (ParticipantClient[ParticipantTopicType], error) {
sd := &info.ServiceDefinition{
Name: "Participant",
ID: rand.NewClientID(),
}
sd.RegisterMethod("RemoveParticipant", false, false, true, true)
sd.RegisterMethod("MutePublishedTrack", false, false, true, true)
sd.RegisterMethod("UpdateParticipant", false, false, true, true)
sd.RegisterMethod("UpdateSubscriptions", false, false, true, true)
sd.RegisterMethod("ForwardParticipant", false, false, true, true)
sd.RegisterMethod("MoveParticipant", false, false, true, true)
sd.RegisterMethod("PerformRpc", false, false, true, true)
rpcClient, err := client.NewRPCClient(sd, bus, opts...)
if err != nil {
return nil, err
}
return &participantClient[ParticipantTopicType]{
client: rpcClient,
}, nil
}
func (c *participantClient[ParticipantTopicType]) RemoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.RoomParticipantIdentity, opts ...psrpc.RequestOption) (*livekit6.RemoveParticipantResponse, error) {
return client.RequestSingle[*livekit6.RemoveParticipantResponse](ctx, c.client, "RemoveParticipant", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) MutePublishedTrack(ctx context.Context, participant ParticipantTopicType, req *livekit6.MuteRoomTrackRequest, opts ...psrpc.RequestOption) (*livekit6.MuteRoomTrackResponse, error) {
return client.RequestSingle[*livekit6.MuteRoomTrackResponse](ctx, c.client, "MutePublishedTrack", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) UpdateParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateParticipantRequest, opts ...psrpc.RequestOption) (*livekit1.ParticipantInfo, error) {
return client.RequestSingle[*livekit1.ParticipantInfo](ctx, c.client, "UpdateParticipant", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) UpdateSubscriptions(ctx context.Context, participant ParticipantTopicType, req *livekit6.UpdateSubscriptionsRequest, opts ...psrpc.RequestOption) (*livekit6.UpdateSubscriptionsResponse, error) {
return client.RequestSingle[*livekit6.UpdateSubscriptionsResponse](ctx, c.client, "UpdateSubscriptions", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) ForwardParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.ForwardParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.ForwardParticipantResponse, error) {
return client.RequestSingle[*livekit6.ForwardParticipantResponse](ctx, c.client, "ForwardParticipant", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) MoveParticipant(ctx context.Context, participant ParticipantTopicType, req *livekit6.MoveParticipantRequest, opts ...psrpc.RequestOption) (*livekit6.MoveParticipantResponse, error) {
return client.RequestSingle[*livekit6.MoveParticipantResponse](ctx, c.client, "MoveParticipant", []string{string(participant)}, req, opts...)
}
func (c *participantClient[ParticipantTopicType]) PerformRpc(ctx context.Context, participant ParticipantTopicType, req *livekit6.PerformRpcRequest, opts ...psrpc.RequestOption) (*livekit6.PerformRpcResponse, error) {
return client.RequestSingle[*livekit6.PerformRpcResponse](ctx, c.client, "PerformRpc", []string{string(participant)}, req, opts...)
}
func (s *participantClient[ParticipantTopicType]) Close() {
s.client.Close()
}
// ==================
// Participant Server
// ==================
type participantServer[ParticipantTopicType ~string] struct {
svc ParticipantServerImpl
rpc *server.RPCServer
}
// NewParticipantServer builds a RPCServer that will route requests
// to the corresponding method in the provided svc implementation.
func NewParticipantServer[ParticipantTopicType ~string](svc ParticipantServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (ParticipantServer[ParticipantTopicType], error) {
sd := &info.ServiceDefinition{
Name: "Participant",
ID: rand.NewServerID(),
}
s := server.NewRPCServer(sd, bus, opts...)
sd.RegisterMethod("RemoveParticipant", false, false, true, true)
sd.RegisterMethod("MutePublishedTrack", false, false, true, true)
sd.RegisterMethod("UpdateParticipant", false, false, true, true)
sd.RegisterMethod("UpdateSubscriptions", false, false, true, true)
sd.RegisterMethod("ForwardParticipant", false, false, true, true)
sd.RegisterMethod("MoveParticipant", false, false, true, true)
sd.RegisterMethod("PerformRpc", false, false, true, true)
return &participantServer[ParticipantTopicType]{
svc: svc,
rpc: s,
}, nil
}
func (s *participantServer[ParticipantTopicType]) RegisterRemoveParticipantTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "RemoveParticipant", []string{string(participant)}, s.svc.RemoveParticipant, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterRemoveParticipantTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("RemoveParticipant", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterMutePublishedTrackTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "MutePublishedTrack", []string{string(participant)}, s.svc.MutePublishedTrack, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterMutePublishedTrackTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("MutePublishedTrack", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterUpdateParticipantTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "UpdateParticipant", []string{string(participant)}, s.svc.UpdateParticipant, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterUpdateParticipantTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("UpdateParticipant", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterUpdateSubscriptionsTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "UpdateSubscriptions", []string{string(participant)}, s.svc.UpdateSubscriptions, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterUpdateSubscriptionsTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("UpdateSubscriptions", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterForwardParticipantTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "ForwardParticipant", []string{string(participant)}, s.svc.ForwardParticipant, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterForwardParticipantTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("ForwardParticipant", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterMoveParticipantTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "MoveParticipant", []string{string(participant)}, s.svc.MoveParticipant, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterMoveParticipantTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("MoveParticipant", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) RegisterPerformRpcTopic(participant ParticipantTopicType) error {
return server.RegisterHandler(s.rpc, "PerformRpc", []string{string(participant)}, s.svc.PerformRpc, nil)
}
func (s *participantServer[ParticipantTopicType]) DeregisterPerformRpcTopic(participant ParticipantTopicType) {
s.rpc.DeregisterHandler("PerformRpc", []string{string(participant)})
}
func (s *participantServer[ParticipantTopicType]) allParticipantTopicRegisterers() server.RegistererSlice {
return server.RegistererSlice{
server.NewRegisterer(s.RegisterRemoveParticipantTopic, s.DeregisterRemoveParticipantTopic),
server.NewRegisterer(s.RegisterMutePublishedTrackTopic, s.DeregisterMutePublishedTrackTopic),
server.NewRegisterer(s.RegisterUpdateParticipantTopic, s.DeregisterUpdateParticipantTopic),
server.NewRegisterer(s.RegisterUpdateSubscriptionsTopic, s.DeregisterUpdateSubscriptionsTopic),
server.NewRegisterer(s.RegisterForwardParticipantTopic, s.DeregisterForwardParticipantTopic),
server.NewRegisterer(s.RegisterMoveParticipantTopic, s.DeregisterMoveParticipantTopic),
server.NewRegisterer(s.RegisterPerformRpcTopic, s.DeregisterPerformRpcTopic),
}
}
func (s *participantServer[ParticipantTopicType]) RegisterAllParticipantTopics(participant ParticipantTopicType) error {
return s.allParticipantTopicRegisterers().Register(participant)
}
func (s *participantServer[ParticipantTopicType]) DeregisterAllParticipantTopics(participant ParticipantTopicType) {
s.allParticipantTopicRegisterers().Deregister(participant)
}
func (s *participantServer[ParticipantTopicType]) Shutdown() {
s.rpc.Close(false)
}
func (s *participantServer[ParticipantTopicType]) Kill() {
s.rpc.Close(true)
}
// ================================
// Participant Unimplemented Server
// ================================
type UnimplementedParticipantServer struct{}
func (UnimplementedParticipantServer) RemoveParticipant(context.Context, *livekit6.RoomParticipantIdentity) (*livekit6.RemoveParticipantResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedParticipantServer) MutePublishedTrack(context.Context, *livekit6.MuteRoomTrackRequest) (*livekit6.MuteRoomTrackResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedParticipantServer) UpdateParticipant(context.Context, *livekit6.UpdateParticipantRequest) (*livekit1.ParticipantInfo, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedParticipantServer) UpdateSubscriptions(context.Context, *livekit6.UpdateSubscriptionsRequest) (*livekit6.UpdateSubscriptionsResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedParticipantServer) ForwardParticipant(context.Context, *livekit6.ForwardParticipantRequest) (*livekit6.ForwardParticipantResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedParticipantServer) MoveParticipant(context.Context, *livekit6.MoveParticipantRequest) (*livekit6.MoveParticipantResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedParticipantServer) PerformRpc(context.Context, *livekit6.PerformRpcRequest) (*livekit6.PerformRpcResponse, error) {
return nil, psrpc.ErrUnimplemented
}
var psrpcFileDescriptor6 = []byte{
// 358 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x4b, 0xc3, 0x40,
0x10, 0x25, 0x08, 0x3d, 0x6c, 0x11, 0xed, 0xaa, 0x50, 0xe2, 0x47, 0x3f, 0xcf, 0x09, 0xe8, 0x3f,
0xf0, 0x20, 0x78, 0x28, 0x94, 0xa8, 0x17, 0x2f, 0x92, 0x6c, 0xb6, 0x76, 0x69, 0x92, 0x59, 0x27,
0x9b, 0x4a, 0xbd, 0x78, 0x10, 0x04, 0xff, 0x8e, 0xff, 0xce, 0x9b, 0x34, 0x69, 0x92, 0x6d, 0x6a,
0x8b, 0x39, 0xee, 0x7b, 0x6f, 0xdf, 0x9b, 0x9d, 0x99, 0x25, 0x27, 0x28, 0x99, 0x2d, 0x5d, 0x54,
0x82, 0x09, 0xe9, 0x46, 0xca, 0x92, 0x08, 0x0a, 0xe8, 0x1e, 0x4a, 0x66, 0xee, 0x83, 0x54, 0x02,
0xa2, 0x38, 0xc3, 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