#ifndef CHAT_SYNC_H #define CHAT_SYNC_H #ifdef __cplusplus extern "C" { #endif #include #include struct UTUN_INSTANCE; struct UASYNC; /* etcp service ID (direct P2P) */ #define ETCP_RT_ID_CHAT_SYNC 0x30 #define ETCP_RT_ID_MEMBER_SYNC 0x31 /* Message types */ #define CS_MSG_INIT_SYNC 0x01 #define CS_MSG_INIT_RESP 0x02 #define CS_MSG_SEND_DATA 0x03 #define CS_MSG_PUSH 0x04 #define CS_MSG_ACK_PUSH 0x05 #define CS_MSG_SYNC_DONE 0x06 #define CS_MSG_ERROR 0x07 #define CS_MSG_CHANNEL_INFO_REQ 0x09 #define CS_MSG_CHANNEL_INFO_RESP 0x0A #define CS_MSG_CHANNEL_JOIN 0x0B #define CS_MSG_WELCOME 0x0C #define CS_MSG_PEER_UPSERT 0x0D #define CS_MSG_PEER_REMOVE 0x0E /* Protocol constants */ #define CS_SEND_DATA_MAX 32 #define CS_MAX_SPARSE 16 #define CS_PEER_TIMEOUT_MS 5000 /* Sync states per channel */ #define CS_SYNC_NONE 0 #define CS_SYNC_IN_PROGRESS 1 #define CS_SYNC_DONE 2 /* ── Public API ── */ int chat_sync_init(struct UTUN_INSTANCE* inst, void (*gui_result_cb)(void*, int, const uint8_t*, int)); void chat_sync_destroy(struct UTUN_INSTANCE* inst); /* Прямое ETCP-подключение к узлу (pubkey+адреса из БД) */ void chat_sync_connect_node(struct UTUN_INSTANCE* inst, uint64_t node_id); /* Подключиться к пиру по данным invite-ссылки (вызывается из GUI-потока) */ void chat_sync_connect_from_invite(uint64_t channel_id, uint64_t node_id, const uint8_t* pubkey_bin, const uint8_t* addrs_data, int addr_count); #ifdef __cplusplus } #endif #endif /* CHAT_SYNC_H */