You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.8 KiB
55 lines
1.8 KiB
/* |
|
* chat_conn_mgr.h — менеджер ETCP-подключений (1 на инстанс) |
|
* |
|
* Управляет подключениями к узлам: перебор адресов, случайный выбор, |
|
* ротация при падении соединения. До CM_MAX_PARALLEL одновременных |
|
* подключений на узел. Фоновый пинг для измерения RTT. |
|
*/ |
|
|
|
#ifndef CHAT_CONN_MGR_H |
|
#define CHAT_CONN_MGR_H |
|
|
|
#include <stdint.h> |
|
#include <stddef.h> |
|
|
|
struct sqlite3; |
|
struct UTUN_INSTANCE; |
|
|
|
/* ── Коды возврата ── */ |
|
#define CC_OK 0 |
|
#define CC_ERR_NOT_FOUND -1 |
|
#define CC_ERR_NO_ADDRESSES -2 |
|
#define CC_ERR_TIMEOUT -3 |
|
#define CC_ERR_UNREACHABLE -4 |
|
#define CC_ERR_INTERNAL -7 |
|
|
|
/* ── Жизненный цикл ── */ |
|
|
|
struct chat_conn_mgr* chat_conn_mgr_init(struct UTUN_INSTANCE* inst, struct sqlite3* db); |
|
void chat_conn_mgr_destroy(struct chat_conn_mgr* mgr); |
|
struct sqlite3* chat_conn_mgr_get_db(struct chat_conn_mgr* mgr); |
|
|
|
/* ── Управление узлами ── */ |
|
|
|
void chat_conn_mgr_add_node(struct chat_conn_mgr* mgr, uint64_t node_id); |
|
|
|
/* ── Подключение ── */ |
|
|
|
void chat_conn_mgr_connect(struct chat_conn_mgr* mgr, uint64_t node_id, |
|
void (*cb)(int result, uint64_t node_id, void* arg), |
|
void* arg); |
|
void chat_conn_mgr_cancel(struct chat_conn_mgr* mgr, uint64_t node_id); |
|
|
|
/* ── invite ── */ |
|
|
|
struct chat_invite { |
|
uint64_t channel_id; |
|
uint64_t node_id; |
|
uint8_t pubkey[32]; |
|
uint8_t* addrs_data; |
|
int addr_count; |
|
}; |
|
|
|
void chat_conn_mgr_connect_from_invite(struct chat_conn_mgr* mgr, struct chat_invite* inv); |
|
|
|
#endif /* CHAT_CONN_MGR_H */
|
|
|