/** * Handler for START message from client, sends information * about all identities to the client immediately and * adds the client to the notification context for future * updates. * * @param cls unused * @param client who sent the message * @param message the message received */ static void handle_start_message (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_IDENTITY_UpdateMessage *um; struct GNUNET_IDENTITY_UpdateMessage ume; struct Ego *ego; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n"); GNUNET_SERVER_notification_context_add (nc, client); for (ego = ego_head; NULL != ego; ego = ego->next) { um = create_update_message (ego); GNUNET_SERVER_notification_context_unicast (nc, client, &um->header, GNUNET_NO); GNUNET_free (um); } memset (&ume, 0, sizeof (ume)); ume.header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); ume.header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage)); ume.end_of_list = htons (GNUNET_YES); ume.name_len = htons (0); GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_NO); GNUNET_SERVER_receive_done (client, GNUNET_OK); }
/** * Handler for START message from client, sends information * about all identities to the client immediately and * adds the client to the notification context for future * updates. * * @param cls unused * @param client who sent the message * @param message the message received */ static void handle_start_message (void *cls, const struct GNUNET_MessageHeader *message) { struct UpdateMessage *ume; struct GNUNET_SERVICE_Client *client = cls; struct GNUNET_MQ_Envelope *env; struct Ego *ego; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n"); GNUNET_SERVICE_client_mark_monitor (client); GNUNET_SERVICE_client_disable_continue_warning (client); GNUNET_notification_context_add (nc, GNUNET_SERVICE_client_get_mq(client)); for (ego = ego_head; NULL != ego; ego = ego->next) { env = create_update_message (ego); GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(client), env); } env = GNUNET_MQ_msg_extra (ume, 0, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); ume->end_of_list = htons (GNUNET_YES); ume->name_len = htons (0); GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq(client), env); GNUNET_SERVICE_client_continue (client); }
/** * Send an updated message for the given ego to all listeners. * * @param ego ego to send the update for */ static void notify_listeners (struct Ego *ego) { struct GNUNET_IDENTITY_UpdateMessage *um; um = create_update_message (ego); GNUNET_SERVER_notification_context_broadcast (nc, &um->header, GNUNET_NO); GNUNET_free (um); }