65 : name(strdup(name)), name_len(name_len), addr(strdup(addr)), port(port) {}
68 :
teoL0Client(name.c_str(), name.size() + 1, addr.c_str(), port) {}
81 namespace unique_raw_ptr {
87 template <
typename T> std::unique_ptr<T[], destroy<T*>>
make(T* raw_data) {
88 std::unique_ptr<T[], destroy<T*>> str_ptr(raw_data);
110 const char* classVersion =
"0.0.4";
132 void* user_data = NULL) {
134 this->event_cb = event_cb;
139 teonet_ptr->
eventCb(e, data, data_len, user_data);
141 options, port, user_data);
185 inline ksnet_arp_data*
sendTo(
const char* to, uint8_t cmd,
void*
data,
size_t data_len)
const {
188 inline ksnet_arp_data*
sendTo(
const char* to, uint8_t cmd,
const std::string&
data)
const {
189 return sendTo((
char*)to, cmd, (
void*)data.c_str(), data.size() + 1);
200 inline void sendToA(
const char* to, uint8_t cmd,
void*
data,
size_t data_len)
const {
203 inline void sendToA(
const char* to, uint8_t cmd,
const std::string&
data)
const {
204 sendToA(to, cmd, (
void*)data.c_str(), data.size() + 1);
219 size_t data_len)
const {
223 sendAnswerTo(rd, (
char*)name, (
void*)data.c_str(), data.size() + 1);
253 if(!
data || !data_len) {
254 data = (
void*)
"Hello Teonet!";
255 data_len = std::strlen((
char*)
data) + 1;
273 inline int sendToL0(
const char* addr,
int port,
const char* cname,
size_t cname_length,
274 uint8_t cmd,
void*
data,
size_t data_len)
const {
275 return ksnLNullSendToL0(ke, (
char*)addr, port, (
char*)cname, cname_length, cmd, data, data_len);
277 inline int sendToL0(
const char* addr,
int port,
const std::string& cname, uint8_t cmd,
void*
data,
278 size_t data_len)
const {
279 return sendToL0(addr, port, cname.c_str(), cname.size() + 1, cmd,
data, data_len);
281 inline int sendToL0(
const char* addr,
int port,
const std::string& cname, uint8_t cmd,
282 const std::string&
data)
const {
283 return sendToL0(addr, port, cname.c_str(), cname.size() + 1, cmd, (
void*)data.c_str(),
314 inline void sendToL0A(
const char* addr,
int port,
const char* cname,
size_t cname_length,
315 uint8_t cmd,
void*
data,
size_t data_len)
const {
317 rd.
from = (
char*)cname;
319 rd.
addr = (
char*)addr;
338 inline int sendEchoToL0(
const char* addr,
int port,
const char* cname,
size_t cname_length,
339 void*
data,
size_t data_len)
const {
344 inline int sendEchoToL0A(
const char* addr,
int port,
const char* cname,
size_t cname_length,
345 void*
data,
size_t data_len)
const {
366 inline void subscribe(
const char* peer_name, uint16_t ev)
const {
369 inline void subscribeA(
const char* peer_name, uint16_t ev)
const {
373 inline void sendToSscr(uint16_t ev,
void*
data,
size_t data_length, uint8_t cmd = 0)
const {
376 inline void sendToSscr(uint16_t ev,
const std::string&
data, uint8_t cmd = 0)
const {
377 sendToSscr(ev, (
void*)data.c_str(), data.size() + 1, cmd);
379 inline void sendToSscrA(uint16_t ev,
const std::string&
data, uint8_t cmd = 0)
const {
380 teoSScrSendA(ke, ev, (
void*)data.c_str(), data.size() + 1, cmd);
421 std::vector<const char*> params_description) {
423 params.insert(params.begin(),
"");
424 params_description.insert(params_description.begin(),
"");
428 app_param.
app_argv =
reinterpret_cast<const char**
>(params.data());
429 app_param.
app_descr =
reinterpret_cast<const char**
>(params_description.data());
439 inline const char*
getParam(
int parm_number)
const {
459 std::string data_path_str(data_path);
461 return data_path_str;
504 inline void metricMs(
const std::string &name,
double value) {
538 if(event_cb) event_cb(*
this, event, data, data_len, user_data);
544 #define teo_printf(module, type, format, ...) \
545 ksnet_printf(&((getKe())->teo_cfg), type, \
546 type != DISPLAY_M ? _ksn_printf_format_(format) \
547 : _ksn_printf_format_display_m(format), \
548 type != DISPLAY_M ? _ksn_printf_type_(type) : "", \
549 type != DISPLAY_M ? (module[0] == '\0' ? (getKe())->teo_cfg.app_name : module) : "", \
550 type != DISPLAY_M ? __func__ : "", type != DISPLAY_M ? __FILE__ : "", \
551 type != DISPLAY_M ? __LINE__ : 0, __VA_ARGS__)
553 #define teo_puts(module, type, format) \
554 ksnet_printf(&((getKe())->teo_cfg), type, \
555 type != DISPLAY_M ? _ksn_printf_format_(format) "\n" \
556 : _ksn_printf_format_display_m(format) "\n", \
557 type != DISPLAY_M ? _ksn_printf_type_(type) : "", \
558 type != DISPLAY_M ? (module[0] == '\0' ? (getKe())->teo_cfg.app_name : module) : "", \
559 type != DISPLAY_M ? __func__ : "", type != DISPLAY_M ? __FILE__ : "", \
560 type != DISPLAY_M ? __LINE__ : 0)
563 #define teo_printf(module, type, format, ...) ;
564 #define teo_puts(module, type, format) ;
567 template <
typename... Arguments>
568 inline std::string
formatMessage(
const char* format,
const Arguments&... args) {
570 std::string str(cstr);
609 template <
typename Callback,
typename T>
610 cqueData*
add(Callback cb, T timeout = 5.00,
void* user_data = NULL) {
616 userData* ud =
new userData{user_data, cb};
618 [](uint32_t
id,
int type,
void*
data) {
619 userData* ud =
static_cast<userData*
>(
data);
620 ud->cb(
id, type, ud->user_data);
623 (double)timeout, ud);
626 template <
typename T>
629 return ksnCQueAdd(kq, cb, (
double)timeout, user_data);
632 template <
typename T>
inline cqueData*
add(T timeout = 5.00,
void* user_data = NULL) {
633 return ksnCQueAdd(kq, NULL, (
double)timeout, user_data);
636 inline int remove(uint32_t id) {
640 template <
typename Callback>
641 inline void*
find(
void*
find,
const Callback compare,
size_t* key_length = NULL) {
645 template <
typename Callback>
646 inline void*
find(
const std::string&
find,
const Callback compare,
size_t* key_length = NULL) {
703 ud->user_data =
data;
733 T cque(
new CQue(
this));
760 return new teoL0Client((
char*)name, name_len, (
char*)addr, port);
766 inline auto getId() const -> decltype((*
tdd)->
id) {
return (*tdd)->id; }
772 inline void*
getKey()
const {
return (*tdd)->key_data; }
775 inline void*
getValue()
const {
return (*tdd)->key_data + (*tdd)->key_length; }
788 : teo(t), tdd(tdd), peer(peer) {
791 : teo(obj.teo), tdd(obj.tdd), peer(obj.peer) {
807 inline const char*
getPeer()
const {
return peer.c_str(); }
809 inline bool checkPeer(
const char* peer_name) {
return !strcmp(peer.c_str(), peer_name); }
811 inline std::unique_ptr<teoDbData>
prepareRequest(
const void* key,
size_t key_len,
812 const void*
data,
size_t data_len, uint32_t
id,
823 inline ksnet_arp_data*
send(uint8_t cmd,
const void* key,
size_t key_len,
824 const void*
data = NULL,
size_t data_len = 0) {
826 return sendTDD(cmd, key, key_len,
data, data_len);
829 template <
typename Callback>
830 ksnet_arp_data*
send(uint8_t cmd,
const void* key,
size_t key_len, Callback cb,
double timeout,
832 void* user_data = NULL) {
836 if(!tdd) tdd = this->tdd;
845 auto ud =
new userData{user_data, cb};
847 [](uint32_t
id,
int type,
void*
data) {
848 userData* ud =
static_cast<userData*
>(
data);
849 ud->cb(
id, type, ud->user_data);
855 return sendTDD(cmd, key, key_len, NULL, 0,
cq->id);
860 teoDbData** tdd = NULL,
void* user_data = NULL) {
864 if(!tdd) tdd = this->tdd;
869 std::cout <<
"!!! cqueCallback !!!\n";
870 auto cq = cque.
add(cb, timeout, user_data);
872 return sendTDD(cmd, key, key_len, NULL, 0,
cq->id);
875 inline int exec(uint32_t
id) {
return cque.
exec(
id); }
879 bool processed =
false;
902 if(*tdd && (*tdd)->
id && !
exec((*tdd)->id)) processed =
true;
915 ksnet_arp_data* sendTDD(uint8_t cmd,
const void* key,
size_t key_len,
const void*
data = NULL,
916 size_t data_len = 0, uint32_t
id = 0) {
920 return teo->
sendTo(peer.c_str(), cmd, tddr.get(), tdd_len);
942 virtual ~PUserData() { std::cout <<
"~PUserData" << std::endl; }
945 template <
typename AnyCallback>
947 const AnyCallback& cb =
nullptr)
const {
950 explicit UserData(
const AnyCallback& cb) : cb(cb) {}
951 virtual ~UserData() { std::cout <<
"~UserData" << std::endl; }
953 auto ud =
new UserData(cb);
956 auto ud =
static_cast<UserData*
>(wd->user_data);
957 ud->cb(data, data_length, wd);
976 std::vector<std::string>
v;
977 std::string to_string() {
978 std::string type_str =
"";
979 for(
size_t i = 0; i < v.size(); i++) { type_str += v[i] + (i < v.size() - 1 ?
"," :
""); }
988 for(
auto i = 0; i < num_dig; i++) {
989 teonetVersion += std::to_string(ver[i]) + (i < num_dig - 1 ?
"." :
"");
994 auto host_info = (host_info_data*)data;
997 for(
auto i = 0; i <= host_info->string_ar_num; i++) {
999 name = host_info->string_ar + ptr;
1000 else if(i == host_info->string_ar_num)
1001 version = host_info->string_ar + ptr;
1003 type.v.push_back(host_info->string_ar + ptr);
1004 ptr += std::char_traits<char>::length(host_info->string_ar + ptr) + 1;
1016 std::string sep =
",";
1019 inline ksnet_stringArr split(
const char* str,
const char* separators,
int with_empty,
1025 inline const char* _to_string(
const char* separator)
const {
1037 explicit StringArray(
const char* str,
const char* separators =
",",
bool with_empty =
true,
1038 int max_parts = 0) {
1040 sa = split(str, separators, with_empty, max_parts);
1044 explicit StringArray(
const std::string& str,
const std::string& separators =
",",
bool with_empty =
true,
1046 :
StringArray(str.c_str(), separators.c_str(), with_empty, max_parts) {
1051 explicit StringArray(
const std::vector<const char*>& vstr,
const char* separators =
",") {
1055 for(
auto& st : vstr)
add(st);
1062 for(
int i = 0; i < ar.
size(); i++) {
add(ar[i]); }
1080 inline std::string
to_string(
const char* separator = NULL)
const {
1081 return std::string(unique_raw_ptr::make<const char>(_to_string(separator)).
get());
1083 inline std::string
to_string(
const std::string& separator)
const {
1086 inline bool move(
unsigned int fromIdx,
unsigned int toIdx) {
1094 using reference =
char*&;
1100 iterator(pointer ptr,
int idx) : ptr_(ptr), idx_(idx) {}
1133 #ifndef THIS_UTILS_H
1134 #define THIS_UTILS_H
1136 #define msg_to_string(msg) \
1138 std::ostringstream foo; \
1143 #define showMessage(mtype, msg) teo_printf("", mtype, "%s", msg_to_string(msg).c_str())
1144 #define showMessageLn(mtype, msg) teo_printf("", mtype, "%s\n", msg_to_string(msg).c_str())
1146 #define watch(x) std::cout << (#x) << " = " << (x) << std::endl
static teo::teoAppParam * appParam(std::vector< const char * > params, std::vector< const char * > params_description)
Create Application parameters.
Definition: teonet.hpp:420
Teonet * getTeonet() const
Get pointer to teonet class object.
Definition: teonet.hpp:801
T getCQue()
CQue class factory(maker)
Definition: teonet.hpp:732
Definition: log_reader.h:38
static teoDbData * getData(teo::teoPacket *rd)
Definition: teonet.hpp:819
#define teo_printf(module, type, format,...)
Definition: teonet.hpp:544
const char * getClassVersion() const
Get this class version.
Definition: teonet.hpp:397
int sendEchoToL0(teoL0Client *l0cli, void *data, size_t data_len) const
Send ECHO command to L0 client with teoL0Client structure.
Definition: teonet.hpp:359
const pointer operator->()
Definition: teonet.hpp:1101
ksnetEvMgrClass * getKe() const
Definition: teonet.hpp:803
Definition: teonet.hpp:737
iterator end()
Definition: teonet.hpp:1117
void teoSetAppVersion(ksnetEvMgrClass *ke, char *version)
Set Teonet application version.
Definition: ev_mgr.c:203
Watcher * open(const char *name, const char *file_name, Flags flags=READ_FROM_BEGIN, const AnyCallback &cb=nullptr) const
Definition: teonet.hpp:946
teoL0Client * l0client
Definition: teonet.hpp:746
virtual ~TeoDB()
Definition: teonet.hpp:793
teoL0Client(const char *name, uint8_t name_len, const char *addr, int port)
Definition: teonet.hpp:64
ksnCQueData * ksnCQueAdd(ksnCQueClass *kq, ksnCQueCallback cb, double timeout, void *data)
Add callback to queue.
Definition: cque.c:260
int ksnLNullSendEchoToL0(void *ke, char *addr, int port, char *cname, size_t cname_length, void *data, size_t data_len)
Send echo to L0 client.
Definition: l0-server.c:510
int run()
Start Teonet Event Manager and network communication.
Definition: teonet.hpp:170
void(* teoEventsCb)(Teonet &teo, teoEvents event, void *data, size_t data_len, void *user_data)
Teonet event callback.
Definition: teonet.hpp:104
Teo DB binary network structure.
Definition: teodb_com.h:45
void * data
Received data.
Definition: net_com.h:117
void operator()(T x)
Definition: teonet.hpp:84
#133 List response: [ key, key, ... ]
Definition: teodb_com.h:25
virtual void cqueueCb(uint32_t id, int type, void *data)
Definition: teonet.hpp:541
void teoSScrSend(teoSScrClass *sscr, uint16_t ev, void *data, size_t data_length, uint8_t cmd)
Send event and it data to all subscribers.
Definition: subscribe.c:58
teo_db_data_range teoDbDataRange
Definition: teonet.hpp:741
ksnetEvMgrClass * getKe() const
Teonet class version.
Definition: teonet.hpp:113
reference operator*()
Definition: teonet.hpp:1113
void sendAnswerToA(teo::teoPacket *rd, uint8_t cmd, const std::string &data) const
Definition: teonet.hpp:239
ksnet_arp_data * send(uint8_t cmd, const void *key, size_t key_len, cqueCallback cb, double timeout, uint8_t cb_type, teo::teoPacket *rd=NULL, teoDbData **tdd=NULL, void *user_data=NULL)
Definition: teonet.hpp:858
uint32_t id
Callback ID (equal to key)
Definition: cque.h:44
void subscribeA(const char *peer_name, uint16_t ev) const
Definition: teonet.hpp:369
const char data[]
Make it with: gcc -o post-callback post-callback.c -lcurl.
Definition: post-callback.c:23
void sendToA(const char *to, uint8_t cmd, const std::string &data) const
Definition: teonet.hpp:203
int sendToL0(const char *addr, int port, const std::string &cname, uint8_t cmd, const std::string &data) const
Definition: teonet.hpp:281
Teonet string array class.
Definition: teonet.hpp:1012
std::unique_ptr< T[], destroy< T * > > make(T *raw_data)
Definition: teonet.hpp:87
uint32_t getId(cqueData *cd) const
Get CQue data id.
Definition: teonet.hpp:678
const char * getHostName() const
Return host name.
Definition: teonet.hpp:411
void teoMetricMs(teoMetricClass *tm, const char *name, double value)
Send time(ms) teonet metric.
Definition: metric.c:132
char * getDataPath(void)
Get path to teonet data folder.
Definition: utils.c:416
ksnet_arp_data * sendTo(const char *to, uint8_t cmd, const std::string &data) const
Definition: teonet.hpp:188
#132 Get data response: { namespace, key, data, data_len, ID } }
Definition: teodb_com.h:24
char * from
Remote peer name.
Definition: net_com.h:112
Teonet class.
Definition: teonet.hpp:98
bool operator==(const iterator &rhs)
Definition: teonet.hpp:1111
virtual ~StringArray()
Definition: teonet.hpp:1066
virtual ~PUserData()
Definition: teonet.hpp:942
ksnet_stringArr ksnet_stringArrCreate()
Create empty c string array.
Definition: string_arr.c:21
void * user_data
Definition: log_reader.h:44
teoDbCQueData(TeoDB *teoDb, teoDbData **tdd, teoL0Client *l0client=NULL, uint8_t cb_type=0)
Definition: teonet.hpp:750
void metricMs(const std::string &name, double value)
Send time(ms) metric.
Definition: teonet.hpp:504
ksnet_arp_data * sendTo(const char *to, uint8_t cmd, void *data, size_t data_len) const
Definition: teonet.hpp:185
StringArray & add(const std::string &str)
Definition: teonet.hpp:1076
void sendToSscrA(uint16_t ev, const std::string &data, uint8_t cmd=0) const
Definition: teonet.hpp:379
TeoDB * teodb
Definition: teonet.hpp:744
std::string teonetVersion
Definition: teonet.hpp:984
teoMetricClass * tm
Metric send module.
Definition: ev_mgr.h:270
int sendEchoTo(const char *to, void *data=NULL, size_t data_len=0) const
Send ECHO command to peer.
Definition: teonet.hpp:252
std::string version
Definition: teonet.hpp:983
int sendEchoToL0A(teoL0Client *l0cli, void *data, size_t data_len) const
Definition: teonet.hpp:362
cqueData * add(Callback cb, T timeout=5.00, void *user_data=NULL)
Add callback to queue.
Definition: teonet.hpp:610
char * ksnetEvMgrGetHostName(ksnetEvMgrClass *ke)
Return host name.
Definition: ev_mgr.c:571
void setAppVersion(const char *version)
Set Teonet application version.
Definition: teonet.hpp:163
uint8_t cb_type
Definition: teonet.hpp:747
void sendAnswerTo(teo::teoPacket *rd, const char *name, void *data, size_t data_len) const
Sent teonet command to peer or l0 client depend of input rd.
Definition: teonet.hpp:218
void ksnCoreSendCmdtoA(void *ke, const char *peer, uint8_t cmd, void *data, size_t data_length)
Definition: async_calls.c:368
void * ksnCQueGetData(ksnCQueClass *kq, uint32_t id)
Get callback queue data.
Definition: cque.c:200
teonet_cfg teo_cfg
KSNet configuration.
Definition: ev_mgr.h:261
ksnCQue Class structure definition
Definition: cque.h:18
int size() const
Definition: teonet.hpp:1071
void subscribe(const char *peer_name, uint16_t ev) const
Definition: teonet.hpp:366
#137 List range response: { listLength, key, ID }
Definition: teodb_com.h:31
int exec(uint32_t id)
Definition: teonet.hpp:875
double ksnetEvMgrGetTime(ksnetEvMgrClass *ke)
Get KSNet event manager time.
Definition: ev_mgr.c:701
CQue & getCQueR()
CQue class factory(maker)
Definition: teonet.hpp:722
StringArray(const std::vector< const char * > &vstr, const char *separators=",")
Definition: teonet.hpp:1051
ksnet_arp_data * send(uint8_t cmd, const void *key, size_t key_len, Callback cb, double timeout, uint8_t cb_type, teo::teoPacket *rd=NULL, teoDbData **tdd=NULL, void *user_data=NULL)
Definition: teonet.hpp:830
void ksnetEvMgrStop(ksnetEvMgrClass *ke)
Stop event manager.
Definition: ev_mgr.c:259
ksnetEvMgrAppParam teoAppParam
Teonet Packet.
Definition: teonet.hpp:56
int app_argc
Definition: ev_mgr.h:234
#5 This host Received a data
Definition: ev_mgr.h:128
Application parameters user data.
Definition: ev_mgr.h:232
void teoMetricCounter(teoMetricClass *tm, const char *name, int value)
Send counter teonet metric.
Definition: metric.c:108
void(* ksnCQueCallback)(uint32_t id, int type, void *data)
ksnCQue callback function definition
Definition: cque.h:34
teoDbData ** tdd
Definition: teonet.hpp:745
CQue(const CQue &obj)
Definition: teonet.hpp:594
cqueData * getData(void *data) const
Get pointer to CQue data structure.
Definition: teonet.hpp:668
void metricGauge(const std::string &name, int value)
Send gauge metric.
Definition: teonet.hpp:514
void stop()
Stop Teonet event manager.
Definition: teonet.hpp:468
Teonet App parameters.
Definition: teonet.hpp:57
teo_db_data teoDbData
Definition: teonet.hpp:740
void * teo_class
Pointer to Teonet c++ Class (in c++ wrapper)
Definition: ev_mgr.h:310
uint8_t from_len
Remote peer name length.
Definition: net_com.h:113
void makeTeonetVersion(uint8_t *ver, int num_dig=DIG_IN_TEO_VER)
Definition: teonet.hpp:986
static const char * getTeonetVersion()
Get Teonet library version.
Definition: teonet.hpp:404
void sendAnswerToA(teo::teoPacket *rd, uint8_t cmd, void *data, size_t data_len) const
Sent teonet command to peer or l0 client depend of input rd (asynchronously)
Definition: teonet.hpp:236
int sendEchoToL0(const char *addr, int port, const char *cname, size_t cname_length, void *data, size_t data_len) const
Send ECHO command to L0 client.
Definition: teonet.hpp:338
CQue(Teonet *t, bool send_event=false)
Definition: teonet.hpp:591
Definition: teonet.hpp:928
KSNet core received data structure.
Definition: net_com.h:107
int sendToL0(const char *addr, int port, const char *cname, size_t cname_length, uint8_t cmd, void *data, size_t data_len) const
Send data to L0 client.
Definition: teonet.hpp:273
teo::teoPacket * getPacket(void *data) const
Cast data to teo::teoPacket.
Definition: teonet.hpp:476
Teonet * getTeonet() const
Get pointer to teonet class object.
Definition: teonet.hpp:685
const char ** app_argv
Definition: ev_mgr.h:235
iterator operator++()
Definition: teonet.hpp:1102
StringArray()
Definition: teonet.hpp:1031
void setAppType(const char *type)
Set Teonet application type.
Definition: teonet.hpp:156
const char * getPeer() const
Definition: teonet.hpp:807
cqueData * add(cqueCallback cb, T timeout=5.00, void *user_data=NULL)
Definition: teonet.hpp:627
HostInfo(void *data)
Definition: teonet.hpp:993
ksnet_stringArr ksnet_stringArrSplit(const char *string, const char *separators, int with_empty, int max_parts)
Split string by separators into words.
Definition: string_arr.c:137
std::string to_string(const std::string &separator) const
Definition: teonet.hpp:1083
iterator(pointer ptr, int idx)
Definition: teonet.hpp:1100
void metricCounter(const std::string &name, double value)
Send counter metric.
Definition: teonet.hpp:494
Definition: teonet.hpp:83
int close(Watcher *wd) const
Definition: teonet.hpp:962
ksnet_arp_data * ksnCoreSendCmdto(ksnCoreClass *kc, char *to, uint8_t cmd, void *data, size_t data_len)
Send command by name to peer.
Definition: net_core.c:389
auto getL0Client() const -> decltype(l0client)
Definition: teonet.hpp:770
void teoBroadcastSend(ksnCoreClass *kc, char *to, uint8_t cmd, void *data, size_t data_len)
Send brodcast command to peers by type.
Definition: net_core.c:358
StringArray(const char *str, const char *separators=",", bool with_empty=true, int max_parts=0)
Definition: teonet.hpp:1037
ksnCQueClass * ksnCQueInit(void *ke, uint8_t send_event)
Initialize ksnCQue module class.
Definition: cque.c:43
LogReader(Teonet &teo)
Definition: teonet.hpp:938
CQue * getCQue()
Definition: teonet.hpp:805
CMD_D_GET_LIST_RANGE extended Data structure.
Definition: teodb_com.h:57
virtual ~CQue()
Definition: teonet.hpp:596
teoL0Client(const std::string &name, const std::string &addr, int port)
Definition: teonet.hpp:67
ksnet_stringArr ksnet_stringArrAdd(ksnet_stringArr *arr, const char *str)
Add c string to string array.
Definition: string_arr.c:33
teo_db_data * prepare_request_data(const void *key, size_t key_len, const void *data, size_t data_len, uint32_t id, size_t *tdd_len)
Prepare teonet db data.
Definition: teodb_com.c:25
int ksnet_stringArrMoveTo(ksnet_stringArr arr, unsigned int fromIdx, unsigned toIdx)
Move array item from one position to another.
Definition: string_arr.c:73
Definition: teonet.hpp:1090
void teoMetricGaugef(teoMetricClass *tm, const char *name, double value)
Send gauge teonet metrics.
Definition: metric.c:156
const char * operator[](int i) const
Definition: teonet.hpp:1069
ksnetEvMgrEvents
KSNet event manager events.
Definition: ev_mgr.h:49
uint32_t teoLogReaderFlag
Definition: log_reader.h:17
ksnetEvMgrClass * ksnetEvMgrInitPort(int argc, char **argv, void(*event_cb)(ksnetEvMgrClass *ke, ksnetEvMgrEvents event, void *data, size_t data_len, void *user_data), int options, int port, void *user_data)
Initialize KSNet Event Manager and network and set new default port.
Definition: ev_mgr.c:104
const char * addr
Definition: teonet.hpp:61
struct teo::HostInfo::@3 type
int sendEchoToL0A(const char *addr, int port, const char *cname, size_t cname_length, void *data, size_t data_len) const
Definition: teonet.hpp:344
iterator begin()
Definition: teonet.hpp:1116
void ksnCQueDestroy(ksnCQueClass *kq)
Destroy ksnCQue module class.
Definition: cque.c:88
void metricGauge(const std::string &name, double value)
Send gauge metric.
Definition: teonet.hpp:524
ksnCommandClass * kco
Command class object.
Definition: net_core.h:48
bool operator!=(const iterator &rhs)
Definition: teonet.hpp:1112
void sendToL0A(const char *addr, int port, const char *cname, size_t cname_length, uint8_t cmd, void *data, size_t data_len) const
Send data to L0 client.
Definition: teonet.hpp:314
char ** ksnet_stringArr
Definition: string_arr.h:11
void * getValue() const
Definition: teonet.hpp:775
int ksnCommandSendCmdEcho(ksnCommandClass *kco, char *to, void *data, size_t data_len)
Send ECHO command to peer.
Definition: net_com.c:283
int ksnLNullSendEchoToL0A(void *ke, char *addr, int port, char *cname, size_t cname_length, void *data, size_t data_len)
Definition: l0-server.c:523
char * getValueStr() const
Definition: teonet.hpp:776
uint8_t name_len
Definition: teonet.hpp:60
KSNet event manager functions data.
Definition: ev_mgr.h:245
iterator operator++(int junk)
Definition: teonet.hpp:1106
teoLogReaderFlag Flags
Definition: teonet.hpp:932
char * getKeyStr() const
Definition: teonet.hpp:773
CQue::cquePtr getCQueP()
CQue class factory(maker)
Definition: teonet.hpp:715
std::vector< std::string > v
Definition: teonet.hpp:976
int ksnetEvMgrRun(ksnetEvMgrClass *ke)
Start KSNet Event Manager and network communication.
Definition: ev_mgr.c:301
void sendToA(const char *to, uint8_t cmd, void *data, size_t data_len) const
Send command by name to peer(asynchronously)
Definition: teonet.hpp:200
std::string name
Definition: teonet.hpp:974
Teonet(int argc, char **argv, teoEventsCb event_cb=NULL, int options=READ_ALL, int port=0, void *user_data=NULL)
Teonet constructor.
Definition: teonet.hpp:131
int sendToL0(teoL0Client *l0cli, uint8_t cmd, void *data, size_t data_len) const
Send data to L0 client with the teoL0Client structure.
Definition: teonet.hpp:297
int teoLogReaderClose(teoLogReaderWatcher *wd)
Definition: log_reader.c:155
ksnetEvMgrEvents teoEvents
Definition: teonet.hpp:54
virtual ~Teonet()
Teonet simple destructor.
Definition: teonet.hpp:148
const char * getParam(int parm_number) const
Get additional application command line parameter defined in teoAppParam.
Definition: teonet.hpp:439
char * ksnet_stringArrCombine(ksnet_stringArr arr, const char *separator)
Combine string array to string.
Definition: string_arr.c:240
void * find(const std::string &find, const Callback compare, size_t *key_length=NULL)
Definition: teonet.hpp:646
TeoDB(Teonet *t, const std::string &peer, teoDbData **tdd)
Definition: teonet.hpp:787
void teoMetricCounterf(teoMetricClass *tm, const char *name, double value)
Send counter teonet metric.
Definition: metric.c:120
void * ksscr
Pointer to teoSScrClass.
Definition: net_com.h:100
teoLogReaderClass * lr
Log reader class.
Definition: ev_mgr.h:266
ksnCQue data structure
Definition: cque.h:39
int ksnCQueRemove(ksnCQueClass *kq, uint32_t id)
Remove callback from queue.
Definition: cque.c:147
TeoDB(const TeoDB &obj)
Definition: teonet.hpp:790
char ** app_argv
Array of application parameters.
Definition: conf.h:91
ksnCoreClass * kc
KSNet core class.
Definition: ev_mgr.h:249
void teoSScrSendA(void *ke, uint16_t event, void *data, size_t data_length, uint8_t cmd)
Definition: async_calls.c:396
ksnCorePacketData teoPacket
Teonet Events.
Definition: teonet.hpp:55
bool move(unsigned int fromIdx, unsigned int toIdx)
Definition: teonet.hpp:1086
ksnet_stringArr ksnet_stringArrFree(ksnet_stringArr *arr)
Free string array.
Definition: string_arr.c:110
double getTime() const
Get KSNet event manager time.
Definition: teonet.hpp:450
int port
Definition: teonet.hpp:62
ksnet_arp_data * send(uint8_t cmd, const void *key, size_t key_len, const void *data=NULL, size_t data_len=0)
Definition: teonet.hpp:823
void sendCmdAnswerToBinaryA(void *ke, void *rdp, uint8_t cmd, void *data, size_t data_length)
Definition: async_calls.c:422
bool checkPeer(const char *peer_name)
Definition: teonet.hpp:809
void teoSetAppType(ksnetEvMgrClass *ke, char *type)
Set Teonet application type.
Definition: ev_mgr.c:192
int l0_f
L0 command flag (from set to l0 client name)
Definition: net_com.h:125
uint32_t id
Request ID.
Definition: teodb_com.h:49
static teoL0Client * setl0Cli(teo::teoPacket *rd)
Definition: teonet.hpp:762
virtual void eventCb(teo::teoEvents event, void *data, size_t data_len, void *user_data)
Virtual Teonet event callback.
Definition: teonet.hpp:536
void setCustomTimer(double time_interval=2.00)
Set custom timer interval.
Definition: teonet.hpp:388
bool process(teoEvents event, void *data)
Definition: teonet.hpp:877
int exec(uint32_t id)
Execute callback queue record.
Definition: teonet.hpp:659
void BroadcastSend(const char *to, uint8_t cmd, void *data, size_t data_len) const
Send command by name to peer.
Definition: teonet.hpp:182
void sendAnswerTo(teo::teoPacket *rd, const char *name, const std::string &data) const
Definition: teonet.hpp:222
StringArray & add(const char *str)
Definition: teonet.hpp:1072
LogReader(Teonet *teo)
Definition: teonet.hpp:939
StringArray & operator=(const StringArray &ar)
Definition: teonet.hpp:1059
void sendToSscr(uint16_t ev, const std::string &data, uint8_t cmd=0) const
Definition: teonet.hpp:376
ksnCQueData cqueData
Definition: teonet.hpp:575
const char * teoGetLibteonetVersion()
Get teonet library version.
Definition: ev_mgr.c:249
std::unique_ptr< teoDbData > prepareRequest(const void *key, size_t key_len, const void *data, size_t data_len, uint32_t id, size_t *tdd_len)
Definition: teonet.hpp:811
#4 Debug message (normal)
Definition: src/utils/utils.h:37
char * ksnet_formatMessage(const char *fmt,...)
Create formated message in new null terminated string.
Definition: utils.c:231
Definition: log_reader.h:19
int ksnLNullSendToL0(void *ke, char *addr, int port, char *cname, size_t cname_length, uint8_t cmd, void *data, size_t data_len)
Send data to L0 client.
Definition: l0-server.c:466
#135 List length response: { listLength, key, ID }
Definition: teodb_com.h:28
static teoL0Client * setl0Cli(const char *name, uint8_t name_len, const char *addr, int port)
Definition: teonet.hpp:758
std::unique_ptr< CQue > cquePtr
Definition: teonet.hpp:584
int setUserData(uint32_t id, void *data)
Set callback queue data, update data set in ksnCQueAdd.
Definition: teonet.hpp:695
virtual ~teoL0Client()
Definition: teonet.hpp:70
auto getId() const -> decltype((*tdd) ->id)
Definition: teonet.hpp:766
void teoSScrSubscribe(teoSScrClass *sscr, char *peer_name, uint16_t ev)
Send command to subscribe this host to event at remote peer.
Definition: subscribe.c:437
void * getCQueData(int id) const
Definition: teonet.hpp:670
cqueData * add(T timeout=5.00, void *user_data=NULL)
Definition: teonet.hpp:632
teoLogReaderWatcher * teoLogReaderOpenCbPP(teoLogReaderClass *lr, const char *name, const char *file_name, teoLogReaderFlag flags, teoLogReaderCallback cb, void *user_data)
Definition: log_reader.c:116
const char ** app_descr
Definition: ev_mgr.h:236
void * getKey() const
Definition: teonet.hpp:772
const char * name
Teonet L0 Client address.
Definition: teonet.hpp:59
const std::string getPath()
Get path to teonet data folder.
Definition: teonet.hpp:457
int ksnet_stringArrLength(ksnet_stringArr arr)
Get length of string array.
Definition: string_arr.c:52
struct teoLogReaderWatcher teoLogReaderWatcher
Definition: log_reader.h:34
void metricCounter(const std::string &name, int value)
Send counter metric.
Definition: teonet.hpp:484
int ksnCQueExec(ksnCQueClass *kq, uint32_t id)
Execute callback queue record.
Definition: cque.c:106
void * find(void *find, const Callback compare, size_t *key_length=NULL)
Definition: teonet.hpp:641
Definition: teonet.hpp:742
void sendToSscr(uint16_t ev, void *data, size_t data_length, uint8_t cmd=0) const
Definition: teonet.hpp:373
void ksnetEvMgrSetCustomTimer(ksnetEvMgrClass *ke, double time_interval)
Set custom timer interval.
Definition: ev_mgr.c:559
struct teo::Teonet::TeoDB::teoDbCQueData teoDbCQueData
ksnCQueCallback cqueCallback
Teonet CQue data structure.
Definition: teonet.hpp:576
Teonet host info processing class.
Definition: teonet.hpp:972
void teoSScrSubscribeA(teoSScrClass *sscr, char *peer, uint16_t ev)
Send command to subscribe this host to event at remote peer.
Definition: async_calls.c:461
void * ksnCQueFindData(ksnCQueClass *kq, void *find, ksnCQueCompare compare, size_t *key_length)
Find data in CQue.
Definition: cque.c:301
void * user_data
Definition: teonet.hpp:748
std::string formatMessage(const char *format, const Arguments &...args)
Definition: teonet.hpp:568
auto getCbType() const -> decltype(cb_type)
Definition: teonet.hpp:768
int sendToL0(const char *addr, int port, const std::string &cname, uint8_t cmd, void *data, size_t data_len) const
Definition: teonet.hpp:277
Definition: teonet.hpp:941
void teoMetricGauge(teoMetricClass *tm, const char *name, int value)
Send gauge teonet metrics.
Definition: metric.c:144
StringArray(const std::string &str, const std::string &separators=",", bool with_empty=true, int max_parts=0)
Definition: teonet.hpp:1044
Teonet CQue callback function.
Definition: teonet.hpp:581
virtual ~teoDbCQueData()
Definition: teonet.hpp:754
File: subscribe.h Author: Kirill Scherba kirill@scherba.ru
Definition: subscribe.h:19
int port
Remote peer port.
Definition: net_com.h:110
std::string to_string(const char *separator=NULL) const
Definition: teonet.hpp:1080
struct teo::teoL0Client teoL0Client
Teonet App parameters.
char * addr
Remote peer IP address.
Definition: net_com.h:109
#define sendCmdAnswerTo(ke, rd, name, out_data, out_data_len)
Sent teonet command to peer or l0 client.
Definition: net_core.h:77