#ifndef SP_BCM_H #define SP_BCM_H #pragma once #ifdef __cplusplus extern "C" { #endif #include "refcnt.h" #include "array.h" #include "sp_uid.h" /** broadcast message */ typedef struct sp_bcm_client_t sp_bcm_client_t; typedef struct sp_bcm_listener_t sp_bcm_listener_t; typedef struct sp_bcm_daemon_t sp_bcm_daemon_t; typedef struct sp_svc_t sp_svc_t; typedef struct iobuffer_t iobuffer_t; typedef struct sp_bcm_listener_cb { void (*on_message)(sp_bcm_listener_t *listener, int from_client_id, int message_id, int message_sig, const void *buf, int len, void *user_data); void (*on_message_raw)(sp_bcm_listener_t *listener, int from_client_id, iobuffer_t **msg_pkt, void *user_data); void (*on_destroy)(sp_bcm_listener_t *listener, void *user_data); void *user_data; }sp_bcm_listener_cb; typedef struct sp_bcm_receiver_t { sp_uid_t id; int receiver_id; char *param; }sp_bcm_receiver_t; // client int sp_bcm_client_create(sp_svc_t *svc, sp_bcm_client_t **p_client); void sp_bcm_client_destroy(sp_bcm_client_t *client); int sp_bcm_client_bcast(sp_bcm_client_t *client, int message_id, int message_sig, iobuffer_t **p_pkt); // listener int sp_bcm_listener_create(sp_svc_t *svc, int target_ent_id, const char *param, const sp_bcm_listener_cb *cb, sp_bcm_listener_t **p_listener); void sp_bcm_listener_destroy(sp_bcm_listener_t *listener); int sp_bcm_listener_subscribe(sp_bcm_listener_t *listener, sp_uid_t *uid); int sp_bcm_listener_unsubscribe(sp_bcm_listener_t *listener); void sp_bcm_listener_set_tag(sp_bcm_listener_t *listener, void *tag); void* sp_bcm_listener_get_tag(sp_bcm_listener_t *listener); void sp_bcm_listener_get_uid(sp_bcm_listener_t *listener, sp_uid_t *uid); int sp_bcm_listener_get_target_entity_id(sp_bcm_listener_t *listener); DECLARE_REF_COUNT(sp_bcm_listener, sp_bcm_listener_t) // daemon SPBASE_API int sp_bcm_daemon_create(sp_svc_t *svc, sp_bcm_daemon_t **p_daemon); SPBASE_API int sp_bcm_deamon_refresh(sp_bcm_daemon_t* daemon); SPBASE_API void sp_bcm_daemon_destroy(sp_bcm_daemon_t *daemon); SPBASE_API array_header_t *sp_bcm_daemon_get_receiver(sp_bcm_daemon_t *daemon, int entity_id); SPBASE_API void sp_bcm_daemon_free_receiver_array(array_header_t *arr_receiver); SPBASE_API int sp_bcm_daemon_process_redirect_subscribe(sp_bcm_daemon_t *daemon, int target_id, const sp_uid_t *uid, int new_target_id); #ifdef __cplusplus } // extern "C" { #endif #endif // SP_BCM_H