|
Teonet library
0.4.7
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "subscribe.h"#include "ev_mgr.h"#include "utils/rlutil.h"Macros | |
| #define | MODULE _ANSI_LIGHTGREEN "subscribe" _ANSI_NONE |
| File: subscribe.c Author: Kirill Scherba kirill@scherba.ru More... | |
| #define | add_data_to_list(sscr_list, peer_name, e, c) |
| #define | kev ((ksnetEvMgrClass*) ((ksnCoreClass *) kco->kc)->ke) |
Typedefs | |
| typedef struct teoSScrMapData | teoSScrMapData |
Functions | |
| teoSScrClass * | teoSScrInit (void *ke) |
| Initialize teoSScr module. More... | |
| void | teoSScrSend (teoSScrClass *sscr, uint16_t ev, void *data, size_t data_length, uint8_t cmd) |
| Send event and it data to all subscribers. More... | |
| int | teoSScrNumberOfSubscribers (teoSScrClass *sscr) |
| Calculate number of subscriptions. More... | |
| int | teoSScrNumberOfEventSubscribers (teoSScrClass *sscr, uint16_t event) |
| Calculate number of subscribers to particular event. More... | |
| void | teoSScrSubscription (teoSScrClass *sscr, char *peer_name, uint16_t ev, ksnet_arp_data *arp_data) |
| Remote peer subscribed to event at this host. More... | |
| int | teoSScrUnSubscription (teoSScrClass *sscr, char *peer_name, uint16_t ev) |
| Remote peer unsubscribed from event at this host. More... | |
| const char * | teoSScrSubscriptionList (teoSScrClass *sscr) |
| Show peers subscribed to this host. More... | |
| int | teoSScrUnSubscriptionAll (teoSScrClass *sscr, char *peer_name) |
| Unsubscribe peer_name from all events. More... | |
| void | teoSScrSubscribe (teoSScrClass *sscr, char *peer_name, uint16_t ev) |
| Send command to subscribe this host to event at remote peer. More... | |
| void | teoSScrUnSubscribe (teoSScrClass *sscr, char *peer_name, uint16_t ev) |
| Send command to unsubscribe this host from event at remote peer. More... | |
| void | teoSScrDestroy (teoSScrClass *sscr) |
| Destroy teoSScr module. More... | |
| int | cmd_subscribe_cb (ksnCommandClass *kco, ksnCorePacketData *rd) |
| Process CMD_SUBSCRIBE, CMD_UNSUBSCRIBE and CMD_SUBSCRIBE_ANSWER commands. More... | |
| #define add_data_to_list | ( | sscr_list, | |
| peer_name, | |||
| e, | |||
| c | |||
| ) |
Referenced by teoSScrSubscription().
| #define kev ((ksnetEvMgrClass*) ((ksnCoreClass *) kco->kc)->ke) |
Referenced by cmd_subscribe_cb().
| #define MODULE _ANSI_LIGHTGREEN "subscribe" _ANSI_NONE |
File: subscribe.c Author: Kirill Scherba kirill@scherba.ru
Created on December 28, 2015, 1:31 PM Subscribe module
Subscribe remote peers to host events events
Referenced by teoSScrSend(), teoSScrSubscription(), and teoSScrUnSubscription().
| typedef struct teoSScrMapData teoSScrMapData |
| int cmd_subscribe_cb | ( | ksnCommandClass * | kco, |
| ksnCorePacketData * | rd | ||
| ) |
Process CMD_SUBSCRIBE, CMD_UNSUBSCRIBE and CMD_SUBSCRIBE_ANSWER commands.
| kco | Pointer to ksnCommandClass |
| rd | Pointer to ksnCorePacketData |
References ksnCorePacketData::arp, ksnCorePacketData::cmd, CMD_SUBSCRIBE, CMD_SUBSCRIBE_ANSWER, CMD_SUBSCRIBE_RND, CMD_UNSUBSCRIBE, ksnCorePacketData::data, ksnCorePacketData::data_len, EV_K_SUBSCRIBE, EV_K_SUBSCRIBED, ksnCorePacketData::from, kev, ksnCommandClass::ksscr, ksnCorePacketData::l0_f, teoSScrSubscription(), and teoSScrUnSubscription().
Referenced by ksnCommandCheck().
| void teoSScrDestroy | ( | teoSScrClass * | sscr | ) |
Destroy teoSScr module.
| sscr | Pointer to ksnCQueClass |
References free(), and teoSScrClass::map.
Referenced by ksnCommandDestroy(), test_6_1(), and test_6_2().
| teoSScrClass* teoSScrInit | ( | void * | ke | ) |
Initialize teoSScr module.
| ke | Pointer to ksnetEvMgrClass |
References teoSScrClass::ke, ke, malloc(), and teoSScrClass::map.
Referenced by ksnCommandInit(), test_6_1(), and test_6_2().
| int teoSScrNumberOfEventSubscribers | ( | teoSScrClass * | sscr, |
| uint16_t | event | ||
| ) |
Calculate number of subscribers to particular event.
| sscr |
References teoSScrClass::map.
| int teoSScrNumberOfSubscribers | ( | teoSScrClass * | sscr | ) |
Calculate number of subscriptions.
| sscr |
References teoSScrClass::map.
Referenced by teoSScrSubscription(), teoSScrUnSubscription(), and test_6_2().
| void teoSScrSend | ( | teoSScrClass * | sscr, |
| uint16_t | ev, | ||
| void * | data, | ||
| size_t | data_length, | ||
| uint8_t | cmd | ||
| ) |
Send event and it data to all subscribers.
| sscr | Pointer to teoSScrClass |
| ev | Event |
| data | Event data |
| data_length | Event data length |
| cmd | Command, used for EV_K_RECEIVED event to show received command |
References teoSScrListData::addr, CMD_SUBSCRIBE_ANSWER, teoSScrListData::data, DEBUG, free(), teoSScrClass::ke, ksn_printf, ksnCoreSendCmdto(), ksnLNullSendToL0(), teoSScrListData::l0_f, malloc(), teoSScrClass::map, MODULE, and teoSScrListData::port.
Referenced by _send_subscribe_event_connected(), _send_subscribe_event_disconnected(), _send_subscribe_event_newvisit(), cmd_disconnected_cb(), event_cb(), event_cb_server(), teo::Teonet::sendToSscr(), and teoSScrSendA().
| void teoSScrSubscribe | ( | teoSScrClass * | sscr, |
| char * | peer_name, | ||
| uint16_t | ev | ||
| ) |
Send command to subscribe this host to event at remote peer.
| sscr | Pointer to teoSScrClass |
| peer_name | Remote host name |
| ev | Event |
References CMD_SUBSCRIBE, teoSScrClass::ke, and ksnCoreSendCmdto().
Referenced by event_cb_client(), teo::Teonet::subscribe(), and teoSScrSubscribeA().
| void teoSScrSubscription | ( | teoSScrClass * | sscr, |
| char * | peer_name, | ||
| uint16_t | ev, | ||
| ksnet_arp_data * | arp_data | ||
| ) |
Remote peer subscribed to event at this host.
Remote peer 'peer_name' has subscribed to the event 'ev' at this host
| sscr | Pointer to teoSScrClass |
| peer_name | Remote peer name |
| ev | Event |
| arp_data | Pointer to arp data if peer_name is L0 client, or NULL if it's a peer |
References add_data_to_list, DEBUG, teoSScrClass::ke, ksn_printf, teoSScrClass::map, MODULE, teoSScrNumberOfSubscribers(), and teoSScrSubscriptionList().
Referenced by cmd_subscribe_cb(), and test_6_2().
| const char* teoSScrSubscriptionList | ( | teoSScrClass * | sscr | ) |
Show peers subscribed to this host.
| sscr |
References teoSScrListData::addr, teoSScrListData::cmd, teoSScrListData::data, teoSScrListData::ev, teoSScrListData::l0_f, teoSScrClass::map, and teoSScrListData::port.
Referenced by hotkeys_cb(), and teoSScrSubscription().
| void teoSScrUnSubscribe | ( | teoSScrClass * | sscr, |
| char * | peer_name, | ||
| uint16_t | ev | ||
| ) |
Send command to unsubscribe this host from event at remote peer.
| sscr | Pointer to teoSScrClass |
| peer_name | Remote host name |
| ev | Event |
References CMD_UNSUBSCRIBE, teoSScrClass::ke, and ksnCoreSendCmdto().
| int teoSScrUnSubscription | ( | teoSScrClass * | sscr, |
| char * | peer_name, | ||
| uint16_t | ev | ||
| ) |
Remote peer unsubscribed from event at this host.
| sscr | Pointer to teoSScrClass |
| peer_name | Remote peer name |
| ev | Event |
References teoSScrListData::data, DEBUG, teoSScrListData::ev, teoSScrClass::ke, ksn_printf, teoSScrClass::map, MODULE, and teoSScrNumberOfSubscribers().
Referenced by cmd_subscribe_cb(), event_cb_server(), teoSScrUnSubscriptionAll(), and test_6_2().
| int teoSScrUnSubscriptionAll | ( | teoSScrClass * | sscr, |
| char * | peer_name | ||
| ) |
Unsubscribe peer_name from all events.
| sscr | |
| peer_name |
References teoSScrClass::map, and teoSScrUnSubscription().
Referenced by test_6_2().