libwebsockets
Lightweight C library for HTML5 websockets
|
Go to the source code of this file.
Data Structures | |
struct | lws_jrpc_method |
Macros | |
#define | LWSJRPCBP_REQ_START_S "{\"jsonrpc\":\"2.0\",\"method\":\"%s\"" |
#define | LWSJRPCBP_REQ_VERSION_S ",\"version\":\"%s\"" |
#define | LWSJRPCBP_REQ_PARAMS ",\"params\":" |
#define | LWSJRPCBP_REQ_NOTIF_END "}" |
#define | LWSJRPCBP_REQ_ID_END_S ",\"id\":%s}" |
#define | LWSJRPCBP_RESP_RESULT "{\"jsonrpc\":\"2.0\",\"result\":" |
#define | LWSJRPCBP_RESP_ID_END_S ",\"id\":%s}" |
#define | LWSJRPCBP_RESP_ERROR_D "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":%d" |
#define | LWSJRPCBP_RESP_ERROR_MSG_S ",\"message\":\"%s\"" |
#define | LWSJRPCBP_RESP_ERROR_DATA ",\"data\":" |
#define | LWSJRPCBP_RESP_ERROR_END "}" |
Typedefs | |
typedef struct lws_jrpc_method | lws_jrpc_method_t |
Enumerations | |
enum | lws_jrpc_cb_return_t { LJRPC_CBRET_CONTINUE , LJRPC_CBRET_WANT_TO_EMIT , LJRPC_CBRET_FINISHED , LJRPC_CBRET_FAILED } |
enum | { LWSJRPCE__NO_ERROR = 0 , LWSJRPCWKE__PARSE_ERROR = -32700 , LWSJRPCWKE__INVALID_REQUEST = -32600 , LWSJRPCWKE__METHOD_NOT_FOUND = -32601 , LWSJRPCWKE__INVALID_PARAMS = -32602 , LWSJRPCWKE__INTERNAL_ERROR = -32603 , LWSJRPCWKE__SERVER_ERROR_FIRST = -32000 , LWSJRPCWKE__SERVER_ERROR_LAST = -32099 , LWSJRPCE__INVALID_MEMBERS = -31000 } |
enum | { LWSJRPC_PARSE_REQUEST , LWSJRPC_PARSE_RESPONSE } |
Functions | |
LWS_VISIBLE LWS_EXTERN int | lws_jrpc_obj_parse (struct lws_jrpc *jrpc, int type, void *opaque, const char *buf, size_t l, struct lws_jrpc_obj **r) |
LWS_VISIBLE LWS_EXTERN void | lws_jrpc_obj_destroy (struct lws_jrpc_obj **_r) |
LWS_VISIBLE LWS_EXTERN void * | lws_jrpc_obj_get_opaque (const struct lws_jrpc_obj *r) |
LWS_VISIBLE LWS_EXTERN const char * | lws_jrpc_obj_id (const struct lws_jrpc_obj *r) |
LWS_VISIBLE LWS_EXTERN struct lws_jrpc * | lws_jrpc_create (const lws_jrpc_method_t *methods, void *opaque) |
LWS_VISIBLE LWS_EXTERN void | lws_jrpc_destroy (struct lws_jrpc **jrpc) |
struct lws_jrpc_method |
Definition at line 77 of file lws-jrpc.h.
Data Fields | ||
---|---|---|
const char * | method_name | |
const char *const * | paths | |
lejp_callback | cb | |
int | count_paths |
#define LWSJRPCBP_REQ_START_S "{\"jsonrpc\":\"2.0\",\"method\":\"%s\"" |
Definition at line 89 of file lws-jrpc.h.
#define LWSJRPCBP_REQ_VERSION_S ",\"version\":\"%s\"" |
Definition at line 91 of file lws-jrpc.h.
#define LWSJRPCBP_REQ_PARAMS ",\"params\":" |
Definition at line 93 of file lws-jrpc.h.
#define LWSJRPCBP_REQ_NOTIF_END "}" |
Definition at line 95 of file lws-jrpc.h.
#define LWSJRPCBP_REQ_ID_END_S ",\"id\":%s}" |
Definition at line 97 of file lws-jrpc.h.
#define LWSJRPCBP_RESP_RESULT "{\"jsonrpc\":\"2.0\",\"result\":" |
Definition at line 104 of file lws-jrpc.h.
#define LWSJRPCBP_RESP_ID_END_S ",\"id\":%s}" |
Definition at line 106 of file lws-jrpc.h.
#define LWSJRPCBP_RESP_ERROR_D "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":%d" |
Definition at line 109 of file lws-jrpc.h.
#define LWSJRPCBP_RESP_ERROR_MSG_S ",\"message\":\"%s\"" |
Definition at line 111 of file lws-jrpc.h.
#define LWSJRPCBP_RESP_ERROR_DATA ",\"data\":" |
Definition at line 113 of file lws-jrpc.h.
#define LWSJRPCBP_RESP_ERROR_END "}" |
Definition at line 115 of file lws-jrpc.h.
typedef struct lws_jrpc_method lws_jrpc_method_t |
enum lws_jrpc_cb_return_t |
Enumerator | |
---|---|
LJRPC_CBRET_CONTINUE | |
LJRPC_CBRET_WANT_TO_EMIT | |
LJRPC_CBRET_FINISHED | |
LJRPC_CBRET_FAILED |
Definition at line 66 of file lws-jrpc.h.
anonymous enum |
Definition at line 121 of file lws-jrpc.h.
anonymous enum |
LWS_VISIBLE LWS_EXTERN int lws_jrpc_obj_parse | ( | struct lws_jrpc * | jrpc, |
int | type, | ||
void * | opaque, | ||
const char * | buf, | ||
size_t | l, | ||
struct lws_jrpc_obj ** | r | ||
) |
lws_jrpc_obj_parse() - parse a request or response
jrpc | the jrpc context this belongs to |
type | LWSJRPC_PARSE_REQUEST or ..._RESPONSE |
opaque | user-defined pointer bound to lws_jrpc, ignored by lws |
buf | chunk of JSON-RPC |
l | remaining length of JSON (may be under or oversize) |
r | NULL to indicate starting new req, already set means continue parse |
If necessary creates an opaque req object and starts parsing len bytes of buf. This may be undersize (more parts coming) in which case req
will be set on entry next time indicating a continuation.
type
and opaque
are ignored if it it's not the first buffer that creates the req object.
Return code is >= 0 if completed, representing the amount of unused data in the input buffer. -1 indicates more input data needed, <-1 indicates an error from the LWSJRPCWKE_ set above, or LEJP_REJECT_UNKNOWN for OOM
LWS_VISIBLE LWS_EXTERN void lws_jrpc_obj_destroy | ( | struct lws_jrpc_obj ** | _r | ) |
LWS_VISIBLE LWS_EXTERN void* lws_jrpc_obj_get_opaque | ( | const struct lws_jrpc_obj * | r | ) |
LWS_VISIBLE LWS_EXTERN const char* lws_jrpc_obj_id | ( | const struct lws_jrpc_obj * | r | ) |
LWS_VISIBLE LWS_EXTERN struct lws_jrpc* lws_jrpc_create | ( | const lws_jrpc_method_t * | methods, |
void * | opaque | ||
) |
lws_jrpc_create() - Allocate and initialize a JRPC context
methods | the method callbacks and names we can process |
opaque | user-defined pointer bound to lws_jrpc ignored by lws |
Allocates an opaque lws_jrpc object and binds it to the given array of method names and callbacks
LWS_VISIBLE LWS_EXTERN void lws_jrpc_destroy | ( | struct lws_jrpc ** | jrpc | ) |