libjapi
0.3.2
Universal JSON API Library
|
Universal JAPI Push Services library. More...
Go to the source code of this file.
Data Structures | |
struct | japi_pushsrv_context |
JAPI push service context. More... | |
Typedefs | |
typedef void(* | japi_pushsrv_routine )(struct __japi_pushsrv_context *psc) |
JAPI push service routine. | |
Functions | |
japi_pushsrv_context * | japi_pushsrv_register (japi_context *ctx, const char *pushsrv_name) |
Register a JAPI push service. More... | |
int | japi_pushsrv_destroy (japi_context *ctx, japi_pushsrv_context *psc) |
Remove push service context from japi context, unsubscribe for all clients and free memory. More... | |
int | japi_pushsrv_sendmsg (japi_pushsrv_context *psc, json_object *jmsg) |
Send messages to all subscribed clients. More... | |
int | japi_pushsrv_start (japi_pushsrv_context *psc, japi_pushsrv_routine routine) |
Start push service routine. More... | |
int | japi_pushsrv_stop (japi_pushsrv_context *psc) |
Stop push service routine. More... | |
Universal JAPI Push Services library.
japi_pushsrv 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_pushsrv_destroy | ( | japi_context * | ctx, |
japi_pushsrv_context * | psc | ||
) |
Remove push service context from japi context, unsubscribe for all clients and free memory.
Clean up the push service if no more needed:
ctx->push_services
ctx | JAPI context |
psc | JAPI push service context which is to be removed |
References japi_pushsrv_context::clients, japi_pushsrv_remove_client(), japi_pushsrv_stop(), japi_pushsrv_context::lock, japi_pushsrv_context::next, japi_client::next, japi_context::push_services, and japi_client::socket.
Referenced by japi_destroy().
japi_pushsrv_context* japi_pushsrv_register | ( | japi_context * | ctx, |
const char * | pushsrv_name | ||
) |
Register a JAPI push service.
Register a JAPI push service specified by pushsrv_name.
ctx | JAPI context |
pushsrv_name | Push-Service name |
References japi_pushsrv_context::clients, japi_pushsrv_context::enabled, japi_pushsrv_context::lock, japi_pushsrv_context::next, japi_context::push_services, japi_pushsrv_context::pushsrv_name, japi_pushsrv_context::routine, japi_pushsrv_context::thread_id, japi_context::userptr, and japi_pushsrv_context::userptr.
int japi_pushsrv_sendmsg | ( | japi_pushsrv_context * | psc, |
json_object * | jmsg | ||
) |
Send messages to all subscribed clients.
Send message to all subscribed clients of a push service.
psc | JAPI push service context |
jmsg | JSON push message |
References japi_pushsrv_context::clients, japi_get_jobj_as_ndstr(), japi_pushsrv_remove_client(), japi_pushsrv_context::lock, japi_client::next, japi_pushsrv_context::pushsrv_name, japi_client::socket, and write_n().
int japi_pushsrv_start | ( | japi_pushsrv_context * | psc, |
japi_pushsrv_routine | routine | ||
) |
Start push service routine.
Create thread and start push service routine.
psc | JAPI push service context |
routine | Thread Push service routine |
References japi_pushsrv_context::enabled, japi_pushsrv_context::routine, and japi_pushsrv_context::thread_id.
int japi_pushsrv_stop | ( | japi_pushsrv_context * | psc | ) |
Stop push service routine.
Wait for thread to end and close it.
psc | JAPI push service context |
References japi_pushsrv_context::enabled, japi_pushsrv_context::pushsrv_name, and japi_pushsrv_context::thread_id.
Referenced by japi_pushsrv_destroy().