- client_activity: desktop/server now ACTIVE by default, only mobile starts STANDBY - topo_group_connect: endless Phase1→2→3→1 cycle until connected - Pause between failed Phase2/3 attempts: 1s active, 30s standby - on_down always triggers cycle_restart when active_conn_count=0 - re-init destroys previous state and starts fresh - CHAT_EVT_CONNECTING_NODES event notifies GUI of current connecting nodes - Android: ConfigProvider default mode='auto', PTT fix, UDP log timer fix
46 lines
1.8 KiB
C
46 lines
1.8 KiB
C
/*
|
|
* chat_event.c — реализация системы нотификаций
|
|
*
|
|
* Пока обработчик не зарегистрирован — события логируются.
|
|
* При регистрации обработчика — форвардятся ему синхронно.
|
|
*/
|
|
|
|
#include "chat_event.h"
|
|
#include "../lib/debug_config.h"
|
|
|
|
#ifdef __ANDROID__
|
|
#include <android/log.h>
|
|
#endif
|
|
|
|
static chat_event_handler_fn g_handler = NULL;
|
|
|
|
void chat_event_set_handler(chat_event_handler_fn handler) {
|
|
#ifdef __ANDROID__
|
|
__android_log_print(ANDROID_LOG_INFO, "utun-evt", "chat_event_set_handler: handler=%p old=%p",
|
|
(void*)handler, (void*)g_handler);
|
|
#endif
|
|
g_handler = handler;
|
|
}
|
|
|
|
void chat_event_post(int type, const uint8_t* data, int len) {
|
|
if (g_handler) { g_handler(type, data, len); return; }
|
|
|
|
static const char* names[] = {
|
|
[1]="MSG_RECEIVED", [2]="CONNECT_RESULT", [3]="NEW_PEER",
|
|
[4]="CHANNEL_UPDATED", [5]="MEMBERS_CHANGED", [6]="MY_NODE_ID",
|
|
[7]="AUTO_CONNECT_STATUS", [8]="CHANNEL_PEERS_ONLINE",
|
|
[9]="DB_READY", [10]="STATUS_REFRESH", [11]="KEYS_GENERATED",
|
|
[12]="SERVICE_STARTED", [13]="SERVICE_STOPPED",
|
|
[14]="ATTACHMENT_DOWNLOADED", [15]="DOWNLOAD_PROGRESS",
|
|
[16]="NODEINFO_UPDATED", [17]="LINK_STATUS_CHANGED",
|
|
[18]="INVITE_RECEIVED", [19]="LOCAL_SOCKETS",
|
|
[20]="CONN_LIST", [21]="CONN_METRICS",
|
|
[22]="MEMBER_DETAIL", [23]="MEMBER_LIST",
|
|
[24]="MEMBER_UPDATED", [25]="MEMBER_REMOVED",
|
|
[26]="BGP_INFO", [27]="CONNECTING_NODES",
|
|
};
|
|
const char* n = (type >= 1 && type <= 27) ? names[type] : "?";
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_CHAT, "chat_event: %s(%d) data=%d bytes", n, type, len);
|
|
if (data && len > 0) log_dump(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_CHAT, " ", data, len);
|
|
}
|