github.com/livekit/protocol@v1.16.1-0.20240517185851-47e4c6bba773/rpc/room.psrpc.go (about) 1 // Code generated by protoc-gen-psrpc v0.5.1, DO NOT EDIT. 2 // source: rpc/room.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 // Room Client Interface 23 // ===================== 24 25 type RoomClient[RoomTopicType ~string] interface { 26 DeleteRoom(ctx context.Context, room RoomTopicType, req *livekit4.DeleteRoomRequest, opts ...psrpc.RequestOption) (*livekit4.DeleteRoomResponse, error) 27 28 SendData(ctx context.Context, room RoomTopicType, req *livekit4.SendDataRequest, opts ...psrpc.RequestOption) (*livekit4.SendDataResponse, error) 29 30 UpdateRoomMetadata(ctx context.Context, room RoomTopicType, req *livekit4.UpdateRoomMetadataRequest, opts ...psrpc.RequestOption) (*livekit.Room, error) 31 } 32 33 // ========================= 34 // Room ServerImpl Interface 35 // ========================= 36 37 type RoomServerImpl interface { 38 DeleteRoom(context.Context, *livekit4.DeleteRoomRequest) (*livekit4.DeleteRoomResponse, error) 39 40 SendData(context.Context, *livekit4.SendDataRequest) (*livekit4.SendDataResponse, error) 41 42 UpdateRoomMetadata(context.Context, *livekit4.UpdateRoomMetadataRequest) (*livekit.Room, error) 43 } 44 45 // ===================== 46 // Room Server Interface 47 // ===================== 48 49 type RoomServer[RoomTopicType ~string] interface { 50 RegisterDeleteRoomTopic(room RoomTopicType) error 51 DeregisterDeleteRoomTopic(room RoomTopicType) 52 RegisterSendDataTopic(room RoomTopicType) error 53 DeregisterSendDataTopic(room RoomTopicType) 54 RegisterUpdateRoomMetadataTopic(room RoomTopicType) error 55 DeregisterUpdateRoomMetadataTopic(room RoomTopicType) 56 RegisterAllRoomTopics(room RoomTopicType) error 57 DeregisterAllRoomTopics(room RoomTopicType) 58 59 // Close and wait for pending RPCs to complete 60 Shutdown() 61 62 // Close immediately, without waiting for pending RPCs 63 Kill() 64 } 65 66 // =========== 67 // Room Client 68 // =========== 69 70 type roomClient[RoomTopicType ~string] struct { 71 client *client.RPCClient 72 } 73 74 // NewRoomClient creates a psrpc client that implements the RoomClient interface. 75 func NewRoomClient[RoomTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (RoomClient[RoomTopicType], error) { 76 sd := &info.ServiceDefinition{ 77 Name: "Room", 78 ID: rand.NewClientID(), 79 } 80 81 sd.RegisterMethod("DeleteRoom", false, false, true, true) 82 sd.RegisterMethod("SendData", false, false, true, true) 83 sd.RegisterMethod("UpdateRoomMetadata", false, false, true, true) 84 85 rpcClient, err := client.NewRPCClient(sd, bus, opts...) 86 if err != nil { 87 return nil, err 88 } 89 90 return &roomClient[RoomTopicType]{ 91 client: rpcClient, 92 }, nil 93 } 94 95 func (c *roomClient[RoomTopicType]) DeleteRoom(ctx context.Context, room RoomTopicType, req *livekit4.DeleteRoomRequest, opts ...psrpc.RequestOption) (*livekit4.DeleteRoomResponse, error) { 96 return client.RequestSingle[*livekit4.DeleteRoomResponse](ctx, c.client, "DeleteRoom", []string{string(room)}, req, opts...) 97 } 98 99 func (c *roomClient[RoomTopicType]) SendData(ctx context.Context, room RoomTopicType, req *livekit4.SendDataRequest, opts ...psrpc.RequestOption) (*livekit4.SendDataResponse, error) { 100 return client.RequestSingle[*livekit4.SendDataResponse](ctx, c.client, "SendData", []string{string(room)}, req, opts...) 101 } 102 103 func (c *roomClient[RoomTopicType]) UpdateRoomMetadata(ctx context.Context, room RoomTopicType, req *livekit4.UpdateRoomMetadataRequest, opts ...psrpc.RequestOption) (*livekit.Room, error) { 104 return client.RequestSingle[*livekit.Room](ctx, c.client, "UpdateRoomMetadata", []string{string(room)}, req, opts...) 105 } 106 107 // =========== 108 // Room Server 109 // =========== 110 111 type roomServer[RoomTopicType ~string] struct { 112 svc RoomServerImpl 113 rpc *server.RPCServer 114 } 115 116 // NewRoomServer builds a RPCServer that will route requests 117 // to the corresponding method in the provided svc implementation. 118 func NewRoomServer[RoomTopicType ~string](svc RoomServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (RoomServer[RoomTopicType], error) { 119 sd := &info.ServiceDefinition{ 120 Name: "Room", 121 ID: rand.NewServerID(), 122 } 123 124 s := server.NewRPCServer(sd, bus, opts...) 125 126 sd.RegisterMethod("DeleteRoom", false, false, true, true) 127 sd.RegisterMethod("SendData", false, false, true, true) 128 sd.RegisterMethod("UpdateRoomMetadata", false, false, true, true) 129 return &roomServer[RoomTopicType]{ 130 svc: svc, 131 rpc: s, 132 }, nil 133 } 134 135 func (s *roomServer[RoomTopicType]) RegisterDeleteRoomTopic(room RoomTopicType) error { 136 return server.RegisterHandler(s.rpc, "DeleteRoom", []string{string(room)}, s.svc.DeleteRoom, nil) 137 } 138 139 func (s *roomServer[RoomTopicType]) DeregisterDeleteRoomTopic(room RoomTopicType) { 140 s.rpc.DeregisterHandler("DeleteRoom", []string{string(room)}) 141 } 142 143 func (s *roomServer[RoomTopicType]) RegisterSendDataTopic(room RoomTopicType) error { 144 return server.RegisterHandler(s.rpc, "SendData", []string{string(room)}, s.svc.SendData, nil) 145 } 146 147 func (s *roomServer[RoomTopicType]) DeregisterSendDataTopic(room RoomTopicType) { 148 s.rpc.DeregisterHandler("SendData", []string{string(room)}) 149 } 150 151 func (s *roomServer[RoomTopicType]) RegisterUpdateRoomMetadataTopic(room RoomTopicType) error { 152 return server.RegisterHandler(s.rpc, "UpdateRoomMetadata", []string{string(room)}, s.svc.UpdateRoomMetadata, nil) 153 } 154 155 func (s *roomServer[RoomTopicType]) DeregisterUpdateRoomMetadataTopic(room RoomTopicType) { 156 s.rpc.DeregisterHandler("UpdateRoomMetadata", []string{string(room)}) 157 } 158 159 func (s *roomServer[RoomTopicType]) allRoomTopicRegisterers() server.RegistererSlice { 160 return server.RegistererSlice{ 161 server.NewRegisterer(s.RegisterDeleteRoomTopic, s.DeregisterDeleteRoomTopic), 162 server.NewRegisterer(s.RegisterSendDataTopic, s.DeregisterSendDataTopic), 163 server.NewRegisterer(s.RegisterUpdateRoomMetadataTopic, s.DeregisterUpdateRoomMetadataTopic), 164 } 165 } 166 167 func (s *roomServer[RoomTopicType]) RegisterAllRoomTopics(room RoomTopicType) error { 168 return s.allRoomTopicRegisterers().Register(room) 169 } 170 171 func (s *roomServer[RoomTopicType]) DeregisterAllRoomTopics(room RoomTopicType) { 172 s.allRoomTopicRegisterers().Deregister(room) 173 } 174 175 func (s *roomServer[RoomTopicType]) Shutdown() { 176 s.rpc.Close(false) 177 } 178 179 func (s *roomServer[RoomTopicType]) Kill() { 180 s.rpc.Close(true) 181 } 182 183 var psrpcFileDescriptor6 = []byte{ 184 // 230 bytes of a gzipped FileDescriptorProto 185 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2b, 0x2a, 0x48, 0xd6, 186 0x2f, 0xca, 0xcf, 0xcf, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2e, 0x2a, 0x48, 0x96, 187 0xe2, 0xcd, 0x2f, 0x28, 0xc9, 0xcc, 0xcf, 0x2b, 0x86, 0x88, 0x49, 0x89, 0xe4, 0x64, 0x96, 0xa5, 188 0x66, 0x67, 0x96, 0xc4, 0xe7, 0xe6, 0xa7, 0xa4, 0xe6, 0xc0, 0x44, 0x85, 0x60, 0xa2, 0x08, 0xdd, 189 0x46, 0xf3, 0x99, 0xb8, 0x58, 0x82, 0xf2, 0xf3, 0x73, 0x85, 0x62, 0xb9, 0xb8, 0x5c, 0x52, 0x73, 190 0x52, 0x4b, 0x52, 0xc1, 0x3c, 0x29, 0x3d, 0xa8, 0x5a, 0x3d, 0x84, 0x60, 0x50, 0x6a, 0x61, 0x69, 191 0x6a, 0x71, 0x89, 0x94, 0x34, 0x56, 0xb9, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x25, 0xb1, 0x4d, 192 0x9d, 0x8c, 0x42, 0x02, 0x8c, 0x52, 0x7c, 0x5c, 0x2c, 0x20, 0x5b, 0x84, 0xc0, 0xa4, 0x04, 0xa3, 193 0x50, 0x38, 0x17, 0x47, 0x70, 0x6a, 0x5e, 0x8a, 0x4b, 0x62, 0x49, 0xa2, 0x90, 0x04, 0xdc, 0x00, 194 0x98, 0x10, 0xcc, 0x68, 0x49, 0x2c, 0x32, 0x04, 0x0c, 0x8e, 0xe7, 0x12, 0x0a, 0x2d, 0x48, 0x49, 195 0x84, 0x38, 0xc3, 0x37, 0xb5, 0x24, 0x31, 0x05, 0x64, 0x85, 0x12, 0xdc, 0x20, 0x4c, 0x49, 0x98, 196 0x65, 0xbc, 0x70, 0x35, 0x20, 0x59, 0x5c, 0x16, 0x38, 0x29, 0x46, 0xc9, 0xa7, 0x67, 0x96, 0x64, 197 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xb5, 0xe8, 0x83, 0x43, 0x2f, 0x39, 0x3f, 0x47, 198 0xbf, 0xa8, 0x20, 0x39, 0x89, 0x0d, 0xcc, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x87, 199 0xc0, 0x3a, 0x9b, 0x01, 0x00, 0x00, 200 }