Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
subscribe.h File Reference
#include <stdint.h>
#include <pbl.h>
#include "teonet_l0_client.h"

Go to the source code of this file.

Data Structures

struct  teoSScrClass
 File: subscribe.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 
struct  teoSScrListData
 teoSScr class list or CMD_SUBSCRIBE_ANSWER data More...
 

Typedefs

typedef struct teoSScrClass teoSScrClass
 File: subscribe.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 
typedef struct teoSScrListData teoSScrListData
 teoSScr class list or CMD_SUBSCRIBE_ANSWER data More...
 

Functions

teoSScrClassteoSScrInit (void *ke)
 Initialize teoSScr module. More...
 
void teoSScrDestroy (teoSScrClass *sscr)
 Destroy teoSScr module. More...
 
void teoSScrSubscription (teoSScrClass *sscr, char *peer_name, uint16_t ev, ksnet_arp_data *arp)
 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...
 
int teoSScrUnSubscriptionAll (teoSScrClass *sscr, char *peer_name)
 Unsubscribe peer_name from all events. More...
 
const char * teoSScrSubscriptionList (teoSScrClass *sscr)
 Show peers subscribed to this host. 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 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...
 

Typedef Documentation

typedef struct teoSScrClass teoSScrClass

File: subscribe.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru

Created on December 28, 2015, 1:31 PM teoSScr Class structure definition

teoSScr class list or CMD_SUBSCRIBE_ANSWER data

Function Documentation

void teoSScrDestroy ( teoSScrClass sscr)

Destroy teoSScr module.

Parameters
sscrPointer to ksnCQueClass

References free(), and teoSScrClass::map.

Referenced by ksnCommandDestroy(), test_6_1(), and test_6_2().

teoSScrClass* teoSScrInit ( void *  ke)

Initialize teoSScr module.

Parameters
kePointer to ksnetEvMgrClass
Returns
Pointer to created teoSScrClass or NULL if error occurred

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.

Parameters
sscr
Returns

References teoSScrClass::map.

int teoSScrNumberOfSubscribers ( teoSScrClass sscr)

Calculate number of subscriptions.

Parameters
sscr
Returns
void teoSScrSend ( teoSScrClass sscr,
uint16_t  ev,
void *  data,
size_t  data_length,
uint8_t  cmd 
)
void teoSScrSubscribe ( teoSScrClass sscr,
char *  peer_name,
uint16_t  ev 
)

Send command to subscribe this host to event at remote peer.

Parameters
sscrPointer to teoSScrClass
peer_nameRemote host name
evEvent

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

Parameters
sscrPointer to teoSScrClass
peer_nameRemote peer name
evEvent
arp_dataPointer 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)
void teoSScrUnSubscribe ( teoSScrClass sscr,
char *  peer_name,
uint16_t  ev 
)

Send command to unsubscribe this host from event at remote peer.

Parameters
sscrPointer to teoSScrClass
peer_nameRemote host name
evEvent

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.

Parameters
sscrPointer to teoSScrClass
peer_nameRemote peer name
evEvent
Returns
True if this peer_name and event was present and successfully removed

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.

Parameters
sscr
peer_name
Returns

References teoSScrClass::map, and teoSScrUnSubscription().

Referenced by test_6_2().