2 This file is part of GNUnet.
3 Copyright (C) 2012-2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
16 * @author Christian Grothoff
19 * General-purpose broadcast mechanism for message queues
21 * @defgroup mq NC library
22 * General-purpose broadcast mechanism for message queues
24 * @see [Documentation](https://gnunet.org/nc)
33 * The notification context is the key datastructure for a convenience
34 * API used for transmission of notifications to the subscriber until the
35 * subscriber disconnects (or the notification context is destroyed, in
36 * which case we disconnect these subscribers). Essentially, all
37 * (notification) messages are queued up until the subscriber is able to
40 struct GNUNET_NotificationContext;
44 * Create a new notification context.
46 * @param queue_length maximum number of messages to keep in
47 * the notification queue; optional messages are dropped
48 * if the queue gets longer than this number of messages
49 * @return handle to the notification context
51 struct GNUNET_NotificationContext *
52 GNUNET_notification_context_create (unsigned int queue_length);
56 * Destroy the context, force disconnect for all subscribers.
58 * @param nc context to destroy.
61 GNUNET_notification_context_destroy (struct GNUNET_NotificationContext *nc);
65 * Add a subscriber to the notification context.
67 * @param nc context to modify
68 * @param mq message queue add
71 GNUNET_notification_context_add (struct GNUNET_NotificationContext *nc,
72 struct GNUNET_MQ_Handle *mq);
76 * Send a message to all subscribers of this context.
78 * @param nc context to modify
79 * @param msg message to send
80 * @param can_drop can this message be dropped due to queue length limitations
83 GNUNET_notification_context_broadcast (struct GNUNET_NotificationContext *nc,
84 const struct GNUNET_MessageHeader *msg,
88 * Return active number of subscribers in this context.
90 * @param nc context to query
91 * @return number of current subscribers
94 GNUNET_notification_context_get_size (struct GNUNET_NotificationContext *nc);