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); }
/** * Function to handle audio data from the client * * @param cls the `struct Line` the message is about * @param msg the message from the client */ static void handle_client_audio_message (void *cls, const struct ClientAudioMessage *msg) { struct Line *line = cls; struct ClientAudioMessage *mam; struct Channel *ch; size_t size; size = ntohs (msg->header.size) - sizeof (struct ClientAudioMessage); ch = find_channel_by_line (line, msg->cid); if (NULL == ch) { /* could have been destroyed asynchronously, ignore message */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel %u not found\n", msg->cid); GNUNET_SERVICE_client_continue (line->client); return; } switch (ch->status) { case CS_CALLEE_INIT: case CS_CALLEE_RINGING: case CS_CALLER_CALLING: GNUNET_break (0); GNUNET_SERVICE_client_drop (line->client); return; case CS_CALLEE_CONNECTED: case CS_CALLER_CONNECTED: /* common case, handled below */ break; case CS_CALLEE_SHUTDOWN: case CS_CALLER_SHUTDOWN: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, "Cadet audio channel in shutdown; audio data dropped\n"); GNUNET_SERVICE_client_continue (line->client); return; } if (GNUNET_YES == ch->suspended_local) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "This channel is suspended locally\n"); GNUNET_SERVICE_client_drop (line->client); return; } if (NULL != ch->env) { /* NOTE: we may want to not do this and instead combine the data */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Bandwidth insufficient; dropping previous audio data segment\n"); GNUNET_MQ_send_cancel (ch->env); ch->env = NULL; } ch->env = GNUNET_MQ_msg_extra (mam, size, GNUNET_MESSAGE_TYPE_CONVERSATION_CADET_AUDIO); GNUNET_memcpy (&mam[1], &msg[1], size); /* FIXME: set options for unreliable transmission */ GNUNET_MQ_notify_sent (ch->env, &channel_audio_sent_notify, ch); GNUNET_MQ_send (ch->mq, ch->env); GNUNET_SERVICE_client_continue (line->client); }