static void test_mq (struct GNUNET_CLIENT_Connection *client) { struct GNUNET_MQ_Handle *mq; struct GNUNET_MQ_Envelope *mqm; /* FIXME: test handling responses */ mq = GNUNET_MQ_queue_for_connection_client (client, NULL, NULL, NULL); mqm = GNUNET_MQ_msg_header (MY_TYPE); GNUNET_MQ_send (mq, mqm); mqm = GNUNET_MQ_msg_header (MY_TYPE); GNUNET_MQ_notify_sent (mqm, send_trap_cb, NULL); GNUNET_MQ_send (mq, mqm); GNUNET_MQ_send_cancel (mqm); mqm = GNUNET_MQ_msg_header (MY_TYPE); GNUNET_MQ_notify_sent (mqm, send_cb, NULL); GNUNET_MQ_send (mq, mqm); }
static void connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s.\n", GNUNET_i2s (peer)); if (0 == memcmp (peer, &myself, sizeof (struct GNUNET_PeerIdentity))) { unsigned int i; struct GNUNET_MQ_Envelope *ev; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing messages.\n"); for (i = 0; i < NUM_MSG; i++) { ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_TEST); GNUNET_MQ_send (mq, ev); } } }
void GNUNET_SET_copy_lazy (struct GNUNET_SET_Handle *set, GNUNET_SET_CopyReadyCallback cb, void *cls) { struct GNUNET_MQ_Envelope *ev; struct SetCopyRequest *req; ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE); GNUNET_MQ_send (set->mq, ev); req = GNUNET_new (struct SetCopyRequest); req->cb = cb; req->cls = cls; GNUNET_CONTAINER_DLL_insert (set->copy_req_head, set->copy_req_tail, req); }
/** * Iterate over all elements in the given set. Note that this * operation involves transferring every element of the set from the * service to the client, and is thus costly. * * @param set the set to iterate over * @param iter the iterator to call for each element * @param iter_cls closure for @a iter * @return #GNUNET_YES if the iteration started successfuly, * #GNUNET_NO if another iteration is active * #GNUNET_SYSERR if the set is invalid (e.g. the server crashed, disconnected) */ int GNUNET_SET_iterate (struct GNUNET_SET_Handle *set, GNUNET_SET_ElementIterator iter, void *iter_cls) { struct GNUNET_MQ_Envelope *ev; GNUNET_assert (NULL != iter); if (GNUNET_YES == set->invalid) return GNUNET_SYSERR; if (NULL != set->iterator) return GNUNET_NO; LOG (GNUNET_ERROR_TYPE_DEBUG, "Iterating over set\n"); set->iterator = iter; set->iterator_cls = iter_cls; ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST); GNUNET_MQ_send (set->mq, ev); return GNUNET_YES; }
/** * Issue a check whether peer is live * * @param peer_ctx the context of the peer */ static void check_peer_live (struct PeerContext *peer_ctx) { LOG (GNUNET_ERROR_TYPE_DEBUG, "Get informed about peer %s getting live\n", GNUNET_i2s (&peer_ctx->peer_id)); struct GNUNET_MQ_Handle *mq; struct GNUNET_MQ_Envelope *ev; ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE); peer_ctx->liveliness_check_pending = GNUNET_new (struct PendingMessage); peer_ctx->liveliness_check_pending->ev = ev; peer_ctx->liveliness_check_pending->peer_ctx = peer_ctx; peer_ctx->liveliness_check_pending->type = "Check liveliness"; mq = get_mq (&peer_ctx->peer_id); GNUNET_MQ_notify_sent (ev, mq_liveliness_check_successful, peer_ctx); GNUNET_MQ_send (mq, ev); }