-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathroom.psrpc.go
More file actions
279 lines (218 loc) · 11.8 KB
/
Copy pathroom.psrpc.go
File metadata and controls
279 lines (218 loc) · 11.8 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
// Code generated by protoc-gen-psrpc v0.7.3, DO NOT EDIT.
// source: rpc/room.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
// =====================
// Room Client Interface
// =====================
type RoomClient[RoomTopicType ~string] interface {
DeleteRoom(ctx context.Context, room RoomTopicType, req *livekit6.DeleteRoomRequest, opts ...psrpc.RequestOption) (*livekit6.DeleteRoomResponse, error)
SendData(ctx context.Context, room RoomTopicType, req *livekit6.SendDataRequest, opts ...psrpc.RequestOption) (*livekit6.SendDataResponse, error)
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) (*livekit1.ParticipantInfo, error)
// Close immediately, without waiting for pending RPCs
Close()
}
// =========================
// Room ServerImpl Interface
// =========================
type RoomServerImpl interface {
DeleteRoom(context.Context, *livekit6.DeleteRoomRequest) (*livekit6.DeleteRoomResponse, error)
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) (*livekit1.ParticipantInfo, error)
}
// =====================
// Room Server Interface
// =====================
type RoomServer[RoomTopicType ~string] interface {
RegisterDeleteRoomTopic(room RoomTopicType) error
DeregisterDeleteRoomTopic(room RoomTopicType)
RegisterSendDataTopic(room RoomTopicType) error
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)
// Close and wait for pending RPCs to complete
Shutdown()
// Close immediately, without waiting for pending RPCs
Kill()
}
// ===========
// Room Client
// ===========
type roomClient[RoomTopicType ~string] struct {
client *client.RPCClient
}
// NewRoomClient creates a psrpc client that implements the RoomClient interface.
func NewRoomClient[RoomTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (RoomClient[RoomTopicType], error) {
sd := &info.ServiceDefinition{
Name: "Room",
ID: rand.NewClientID(),
}
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 {
return nil, err
}
return &roomClient[RoomTopicType]{
client: rpcClient,
}, nil
}
func (c *roomClient[RoomTopicType]) DeleteRoom(ctx context.Context, room RoomTopicType, req *livekit6.DeleteRoomRequest, opts ...psrpc.RequestOption) (*livekit6.DeleteRoomResponse, error) {
return client.RequestSingle[*livekit6.DeleteRoomResponse](ctx, c.client, "DeleteRoom", []string{string(room)}, req, opts...)
}
func (c *roomClient[RoomTopicType]) SendData(ctx context.Context, room RoomTopicType, req *livekit6.SendDataRequest, opts ...psrpc.RequestOption) (*livekit6.SendDataResponse, error) {
return client.RequestSingle[*livekit6.SendDataResponse](ctx, c.client, "SendData", []string{string(room)}, req, opts...)
}
func (c *roomClient[RoomTopicType]) UpdateRoomMetadata(ctx context.Context, room RoomTopicType, req *livekit6.UpdateRoomMetadataRequest, opts ...psrpc.RequestOption) (*livekit1.Room, error) {
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) (*livekit1.ParticipantInfo, error) {
return client.RequestSingle[*livekit1.ParticipantInfo](ctx, c.client, "GetParticipant", []string{string(room)}, req, opts...)
}
func (s *roomClient[RoomTopicType]) Close() {
s.client.Close()
}
// ===========
// Room Server
// ===========
type roomServer[RoomTopicType ~string] struct {
svc RoomServerImpl
rpc *server.RPCServer
}
// NewRoomServer builds a RPCServer that will route requests
// to the corresponding method in the provided svc implementation.
func NewRoomServer[RoomTopicType ~string](svc RoomServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (RoomServer[RoomTopicType], error) {
sd := &info.ServiceDefinition{
Name: "Room",
ID: rand.NewServerID(),
}
s := server.NewRPCServer(sd, bus, opts...)
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,
}, nil
}
func (s *roomServer[RoomTopicType]) RegisterDeleteRoomTopic(room RoomTopicType) error {
return server.RegisterHandler(s.rpc, "DeleteRoom", []string{string(room)}, s.svc.DeleteRoom, nil)
}
func (s *roomServer[RoomTopicType]) DeregisterDeleteRoomTopic(room RoomTopicType) {
s.rpc.DeregisterHandler("DeleteRoom", []string{string(room)})
}
func (s *roomServer[RoomTopicType]) RegisterSendDataTopic(room RoomTopicType) error {
return server.RegisterHandler(s.rpc, "SendData", []string{string(room)}, s.svc.SendData, nil)
}
func (s *roomServer[RoomTopicType]) DeregisterSendDataTopic(room RoomTopicType) {
s.rpc.DeregisterHandler("SendData", []string{string(room)})
}
func (s *roomServer[RoomTopicType]) RegisterUpdateRoomMetadataTopic(room RoomTopicType) error {
return server.RegisterHandler(s.rpc, "UpdateRoomMetadata", []string{string(room)}, s.svc.UpdateRoomMetadata, nil)
}
func (s *roomServer[RoomTopicType]) DeregisterUpdateRoomMetadataTopic(room RoomTopicType) {
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),
}
}
func (s *roomServer[RoomTopicType]) RegisterAllRoomTopics(room RoomTopicType) error {
return s.allRoomTopicRegisterers().Register(room)
}
func (s *roomServer[RoomTopicType]) DeregisterAllRoomTopics(room RoomTopicType) {
s.allRoomTopicRegisterers().Deregister(room)
}
func (s *roomServer[RoomTopicType]) Shutdown() {
s.rpc.Close(false)
}
func (s *roomServer[RoomTopicType]) Kill() {
s.rpc.Close(true)
}
// =========================
// Room Unimplemented Server
// =========================
type UnimplementedRoomServer struct{}
func (UnimplementedRoomServer) DeleteRoom(context.Context, *livekit6.DeleteRoomRequest) (*livekit6.DeleteRoomResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedRoomServer) SendData(context.Context, *livekit6.SendDataRequest) (*livekit6.SendDataResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedRoomServer) UpdateRoomMetadata(context.Context, *livekit6.UpdateRoomMetadataRequest) (*livekit1.Room, error) {
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) (*livekit1.ParticipantInfo, error) {
return nil, psrpc.ErrUnimplemented
}
var psrpcFileDescriptor7 = []byte{
// 290 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xe1, 0x4a, 0xfb, 0x30,
0x14, 0xc5, 0x29, 0x1b, 0x7f, 0xfe, 0x04, 0x56, 0x46, 0x10, 0x99, 0xf1, 0x83, 0x6e, 0x0f, 0xd0,
0x82, 0xbe, 0x81, 0x0c, 0x44, 0x50, 0x90, 0x89, 0x08, 0x82, 0x8c, 0x2c, 0xb9, 0x6a, 0xb0, 0xcd,
0x8d, 0xc9, 0x9d, 0xe0, 0x23, 0xf8, 0x3a, 0x3e, 0x9c, 0x9f, 0xa5, 0xdd, 0xd2, 0x16, 0xdd, 0xdc,
0x97, 0xc2, 0x3d, 0xbf, 0x7b, 0xce, 0xb9, 0x2d, 0x65, 0xa9, 0x77, 0x2a, 0xf7, 0x88, 0x65, 0xe6,
0x3c, 0x12, 0xf2, 0x9e, 0x77, 0x4a, 0x0c, 0xd0, 0x91, 0x41, 0x1b, 0x56, 0x9a, 0xd8, 0x2b, 0xcc,
0x1b, 0xbc, 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