HomeScreenBinding
|
#include <libhomescreen.hpp>
Public Types | |
enum | EventType { Event_TapShortcut = 1, Event_OnScreenMessage, Event_OnScreenReply } |
using | handler_func = std::function< void(json_object *)> |
Public Member Functions | |
LibHomeScreen () | |
~LibHomeScreen () | |
LibHomeScreen (const LibHomeScreen &)=delete | |
LibHomeScreen & | operator= (const LibHomeScreen &)=delete |
int | init (const int port, const std::string &token) |
int | tapShortcut (const char *application_name) |
int | onScreenMessage (const char *display_message) |
int | onScreenReply (const char *reply_message) |
void | set_event_handler (enum EventType et, handler_func f) |
void | registerCallback (void(*event_cb)(const std::string &event, struct json_object *event_contents), void(*reply_cb)(struct json_object *reply_contents), void(*hangup_cb)(void)=nullptr) |
int | call (const std::string &verb, struct json_object *arg) |
int | call (const char *verb, struct json_object *arg) |
int | subscribe (const std::string &event_name) |
int | unsubscribe (const std::string &event_name) |
void | on_hangup (void *closure, struct afb_wsj1 *wsj) |
void | on_call (void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg) |
void | on_event (void *closure, const char *event, struct afb_wsj1_msg *msg) |
void | on_reply (void *closure, struct afb_wsj1_msg *msg) |
Static Public Attributes | |
static const std::vector< std::string > | api_list |
static const std::vector< std::string > | event_list |
Definition at line 32 of file libhomescreen.hpp.
using LibHomeScreen::handler_func = std::function<void(json_object*)> |
Definition at line 42 of file libhomescreen.hpp.
Enumerator | |
---|---|
Event_TapShortcut | |
Event_OnScreenMessage | |
Event_OnScreenReply |
Definition at line 44 of file libhomescreen.hpp.
LibHomeScreen::LibHomeScreen | ( | ) |
LibHomeScreen::~LibHomeScreen | ( | ) |
destructor
Definition at line 90 of file libhomescreen.cpp.
|
delete |
int LibHomeScreen::call | ( | const std::string & | verb, |
struct json_object * | arg | ||
) |
int LibHomeScreen::call | ( | const char * | verb, |
struct json_object * | arg | ||
) |
This function calls the API of HomeScreen via WebSocket This function is overload function of "call"
To call HomeScreen's APIs, the application should set its function name, arguments to JSON format.
Definition at line 360 of file libhomescreen.cpp.
int LibHomeScreen::init | ( | const int | port, |
const std::string & | token | ||
) |
This function is initializer
Nothing
Use this constructor
Definition at line 116 of file libhomescreen.cpp.
void LibHomeScreen::on_call | ( | void * | closure, |
const char * | api, | ||
const char * | verb, | ||
struct afb_wsj1_msg * | msg | ||
) |
Definition at line 448 of file libhomescreen.cpp.
void LibHomeScreen::on_event | ( | void * | closure, |
const char * | event, | ||
struct afb_wsj1_msg * | msg | ||
) |
Definition at line 458 of file libhomescreen.cpp.
void LibHomeScreen::on_hangup | ( | void * | closure, |
struct afb_wsj1 * | wsj | ||
) |
Definition at line 439 of file libhomescreen.cpp.
void LibHomeScreen::on_reply | ( | void * | closure, |
struct afb_wsj1_msg * | msg | ||
) |
msg is like ({"response":{"verb":"subscribe","error":0},"jtype":"afb-reply","request":{"status":"success","info":"homescreen binder subscribe event name [on_screen_message]"}}) msg is like ({"response":{"verb":"tap_shortcut","error":0},"jtype":"afb-reply","request":{"status":"success","info":"afb_event_push event [tap_shortcut]"}})
Definition at line 506 of file libhomescreen.cpp.
int LibHomeScreen::onScreenMessage | ( | const char * | display_message | ) |
Sending onScreen message event
Sending OnScreen message event to HomeScreen from applications
Definition at line 244 of file libhomescreen.cpp.
int LibHomeScreen::onScreenReply | ( | const char * | reply_message | ) |
Sending onScreen reply event
Sending OnScreen reply event to applications from HomeScreen
Definition at line 268 of file libhomescreen.cpp.
|
delete |
void LibHomeScreen::registerCallback | ( | void(*)(const std::string &event, struct json_object *event_contents) | event_cb, |
void(*)(struct json_object *reply_contents) | reply_cb, | ||
void(*)(void) | hangup_cb = nullptr |
||
) |
This function register callback function for reply/event message from home screen
Nothing
Event callback is invoked by home screen for event you subscribed. If you would like to get event, please call subscribe function before/after this function
Definition at line 155 of file libhomescreen.cpp.
void LibHomeScreen::set_event_handler | ( | enum EventType | et, |
handler_func | f | ||
) |
Setting Event Handler
Setting event handler for Homescreen
Nothing
Definition at line 293 of file libhomescreen.cpp.
int LibHomeScreen::subscribe | ( | const std::string & | event_name | ) |
Register callback function for each event
This function enables to get an event to your callback function.
Definition at line 392 of file libhomescreen.cpp.
int LibHomeScreen::tapShortcut | ( | const char * | application_name | ) |
Sending ShortCut Icon tapped event
When HomeScreen shortcut area is tapped, sending a event
Definition at line 220 of file libhomescreen.cpp.
int LibHomeScreen::unsubscribe | ( | const std::string & | event_name | ) |
Unregister callback function for each event
This function disables to get an event to your callback function.
Definition at line 421 of file libhomescreen.cpp.
|
static |
Definition at line 50 of file libhomescreen.hpp.
|
static |
Definition at line 51 of file libhomescreen.hpp.