LiveKit ESP32 SDK
Loading...
Searching...
No Matches
livekit_rpc.h
1
2#pragma once
3
4#include <stdbool.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
12#define LIVEKIT_RPC_MAX_PAYLOAD_BYTES 15360 // 15 KB
13
15typedef enum {
17 LIVEKIT_RPC_RESULT_OK = 0,
18
20 LIVEKIT_RPC_RESULT_APPLICATION = 1500,
21
23 LIVEKIT_RPC_RESULT_CONNECTION_TIMEOUT = 1501,
24
26 LIVEKIT_RPC_RESULT_RESPONSE_TIMEOUT = 1502,
27
29 LIVEKIT_RPC_RESULT_RECIPIENT_DISCONNECTED = 1503,
30
32 LIVEKIT_RPC_RESULT_RESPONSE_PAYLOAD_TOO_LARGE = 1504,
33
35 LIVEKIT_RPC_RESULT_SEND_FAILED = 1505,
36
38 LIVEKIT_RPC_RESULT_UNSUPPORTED_METHOD = 1400,
39
41 LIVEKIT_RPC_RESULT_RECIPIENT_NOT_FOUND = 1401,
42
44 LIVEKIT_RPC_RESULT_REQUEST_PAYLOAD_TOO_LARGE = 1402,
45
47 LIVEKIT_RPC_RESULT_UNSUPPORTED_SERVER = 1403,
48
50 LIVEKIT_RPC_RESULT_UNSUPPORTED_VERSION = 1404
51} livekit_rpc_result_code_t;
52
54typedef struct {
56 char* id;
57
60 livekit_rpc_result_code_t code;
61
64
66 char* payload;
68
70typedef struct {
72 char* id;
73
75 char* method;
76
79
85 char* payload;
86
88 bool (*send_result)(const livekit_rpc_result_t* res, void* ctx);
89
91 void *ctx;
93
96typedef void (*livekit_rpc_handler_t)(const livekit_rpc_invocation_t* invocation, void* ctx);
97
102#define livekit_rpc_return_ok(_payload) \
103 invocation->send_result(&(livekit_rpc_result_t){ \
104 .id = invocation->id, \
105 .code = LIVEKIT_RPC_RESULT_OK, \
106 .payload = (_payload), \
107 .error_message = NULL \
108 }, invocation->ctx)
109
114#define livekit_rpc_return_error(_error_message) \
115 invocation->send_result(&(livekit_rpc_result_t){ \
116 .id = invocation->id, \
117 .code = LIVEKIT_RPC_RESULT_APPLICATION, \
118 .payload = NULL, \
119 .error_message = (_error_message) \
120 }, invocation->ctx);
121
122#ifdef __cplusplus
123}
124#endif
void(* livekit_rpc_handler_t)(const livekit_rpc_invocation_t *invocation, void *ctx)
Handler for an RPC invocation.
Definition livekit_rpc.h:96
char * id
Invocation identifier.
Definition livekit_rpc.h:56
char * payload
Payload returned to the caller.
Definition livekit_rpc.h:66
char * payload
Caller provided payload.
Definition livekit_rpc.h:85
char * method
The name of the method being invoked.
Definition livekit_rpc.h:75
char * id
Invocation identifier.
Definition livekit_rpc.h:72
void * ctx
Context for the callback.
Definition livekit_rpc.h:91
livekit_rpc_result_code_t code
The error code if the RPC method failed.
Definition livekit_rpc.h:60
char * error_message
Optional, textual description of the error that occurred.
Definition livekit_rpc.h:63
char * caller_identity
Participant identity of the caller.
Definition livekit_rpc.h:78
bool(* send_result)(const livekit_rpc_result_t *res, void *ctx)
Sends the result of the invocation to the caller.
Definition livekit_rpc.h:88
Details about an RPC method invocation.
Definition livekit_rpc.h:70
The result of an RPC method invocation.
Definition livekit_rpc.h:54