libjapi
0.3.2
Universal JSON API Library
|
Internal functions of the JSON API library. More...
Go to the source code of this file.
Functions | |
int | japi_process_message (japi_context *ctx, const char *request, char **response, int socket) |
Process the JSON request. More... | |
int | japi_pushsrv_remove_client (japi_pushsrv_context *psc, int socket) |
Remove client from push service. More... | |
int | japi_remove_client (japi_context *ctx, int socket) |
Remove client. More... | |
int | japi_remove_all_clients (japi_context *ctx) |
Remove all clients. More... | |
int | japi_add_client (japi_context *ctx, int socket) |
Add client. More... | |
void | japi_pushsrv_remove_client_from_all_pushsrv (japi_context *ctx, int socket) |
Remove client from all push services. More... | |
void | japi_cmd_list (japi_context *ctx, json_object *request, json_object *response) |
Provide the names of all registered commands as a JAPI response. More... | |
void | japi_request_not_found_handler (japi_context *ctx, json_object *request, json_object *response) |
Default handler for reacting to unknown requests. More... | |
Internal functions of the JSON API library.
libjapi is a universal JSON API library.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
int japi_add_client | ( | japi_context * | ctx, |
int | socket | ||
) |
Add client.
Add client to JAPI context client list.
ctx | JAPI context |
socket | The socket to be added |
References japi_context::clients, japi_client::crl_buffer, japi_context::lock, creadline_buf_t::nbytes, japi_client::next, japi_context::num_clients, and japi_client::socket.
Referenced by japi_start_server().
void japi_cmd_list | ( | japi_context * | ctx, |
json_object * | request, | ||
json_object * | response | ||
) |
Provide the names of all registered commands as a JAPI response.
Provides the names of all registered commands as a JAPI response.
ctx | JAPI context |
request | Pointer to JAPI JSON request |
response | Pointer to JAPI JSON response |
References japi_request::name, japi_request::next, and japi_context::requests.
Referenced by japi_init().
int japi_process_message | ( | japi_context * | ctx, |
const char * | request, | ||
char ** | response, | ||
int | socket | ||
) |
Process the JSON request.
Steps performed while processing a JSON request:
ctx | Japi context |
request | Request to process |
response | From request build response |
socket | Network socket |
References japi_context::include_args_in_response, japi_get_jobj_as_ndstr(), and japi_get_value_as_str().
Referenced by japi_start_server().
int japi_pushsrv_remove_client | ( | japi_pushsrv_context * | psc, |
int | socket | ||
) |
Remove client from push service.
Remove client socket from given push service.
psc | JAPI push service context |
socket | Socket to remove |
References japi_pushsrv_context::clients, japi_client::next, japi_pushsrv_context::pushsrv_name, and japi_client::socket.
Referenced by japi_pushsrv_destroy(), japi_pushsrv_remove_client_from_all_pushsrv(), japi_pushsrv_sendmsg(), and japi_pushsrv_unsubscribe().
void japi_pushsrv_remove_client_from_all_pushsrv | ( | japi_context * | ctx, |
int | socket | ||
) |
Remove client from all push services.
Removes given client from all JAPI push service clients.
ctx | JAPI context |
socket | The socket to be removed |
References japi_pushsrv_remove_client(), japi_pushsrv_context::lock, japi_pushsrv_context::next, and japi_context::push_services.
Referenced by japi_remove_client().
int japi_remove_all_clients | ( | japi_context * | ctx | ) |
Remove all clients.
Remove all clients from JAPI context and pushs service context.
ctx | JAPI context |
References japi_context::clients, japi_remove_client(), japi_client::next, and japi_client::socket.
Referenced by japi_start_server().
int japi_remove_client | ( | japi_context * | ctx, |
int | socket | ||
) |
Remove client.
Remove client from JAPI context and pushs service context.
ctx | JAPI context |
socket | The socket to be removed |
References japi_context::clients, japi_pushsrv_remove_client_from_all_pushsrv(), japi_context::lock, japi_client::next, japi_context::num_clients, and japi_client::socket.
Referenced by japi_remove_all_clients(), and japi_start_server().
void japi_request_not_found_handler | ( | japi_context * | ctx, |
json_object * | request, | ||
json_object * | response | ||
) |
Default handler for reacting to unknown requests.
Can be overwritten by the user by registering a command called request_not_found_handler
. Is called if no suitable registered request is found for the received command. Adds a field named "error" to the response which contains a string describing the issue.
ctx | JAPI context |
request | Pointer to JAPI JSON request |
response | Pointer to JAPI JSON response |
Referenced by japi_init().