Add enhanced subscription functionality with EOSE result modes
This commit is contained in:
@@ -62,9 +62,17 @@ void on_event(cJSON* event, const char* relay_url, void* user_data) {
|
||||
}
|
||||
|
||||
// EOSE callback - called when End of Stored Events is received
|
||||
void on_eose(void* user_data) {
|
||||
void on_eose(cJSON** events, int event_count, void* user_data) {
|
||||
(void)user_data; // Suppress unused parameter warning
|
||||
printf("📋 EOSE received - all stored events delivered\n");
|
||||
printf("📋 EOSE received - %d events collected\n", event_count);
|
||||
|
||||
// Log collected events if any
|
||||
for (int i = 0; i < event_count; i++) {
|
||||
cJSON* id = cJSON_GetObjectItem(events[i], "id");
|
||||
if (id && cJSON_IsString(id)) {
|
||||
printf(" Event %d: %.12s...\n", i + 1, cJSON_GetStringValue(id));
|
||||
}
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@@ -174,7 +182,7 @@ int main() {
|
||||
printf("%s\n\n", filter_json);
|
||||
free(filter_json);
|
||||
|
||||
// Create subscription
|
||||
// Create subscription with new parameters
|
||||
nostr_pool_subscription_t* subscription = nostr_relay_pool_subscribe(
|
||||
pool,
|
||||
relay_urls,
|
||||
@@ -183,7 +191,11 @@ int main() {
|
||||
on_event, // Event callback
|
||||
on_eose, // EOSE callback
|
||||
NULL, // User data (not used)
|
||||
0 // close_on_eose (false - keep subscription open)
|
||||
0, // close_on_eose (false - keep subscription open)
|
||||
1, // enable_deduplication
|
||||
NOSTR_POOL_EOSE_FULL_SET, // result_mode
|
||||
30, // relay_timeout_seconds
|
||||
60 // eose_timeout_seconds
|
||||
);
|
||||
|
||||
if (!subscription) {
|
||||
|
||||
Reference in New Issue
Block a user