/// <summary>
        /// Sends a FindObjectsResponse message to a customer.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="objects">The list of <see cref="DataObject" /> objects.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <returns>The message identifier.</returns>
        public virtual long FindObjectsResponse(IMessageHeader request, IList <DataObject> objects, string sortOrder)
        {
            if (!objects.Any())
            {
                return(Acknowledge(request.MessageId, MessageFlags.NoData));
            }

            long messageId = 0;

            for (var i = 0; i < objects.Count; i++)
            {
                var messageFlags = i < objects.Count - 1
                    ? MessageFlags.MultiPart
                    : MessageFlags.MultiPartAndFinalPart;

                var header = CreateMessageHeader(Protocols.StoreQuery, MessageTypes.StoreQuery.FindObjectsResponse, request.MessageId, messageFlags);

                var response = new FindObjectsResponse
                {
                    DataObjects     = new[] { objects[i] },
                    ServerSortOrder = sortOrder ?? string.Empty
                };

                messageId = Session.SendMessage(header, response);
                sortOrder = string.Empty; // Only needs to be set in the first message
            }

            return(messageId);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the FindObjectsResponse message from a store.
        /// </summary>
        /// <param name="header">The message header.</param>
        /// <param name="findObjectsResponse">The FindObjectsResponse message.</param>
        protected virtual void HandleFindObjectsResponse(IMessageHeader header, FindObjectsResponse findObjectsResponse)
        {
            var uri  = GetRequestedUri(header);
            var args = Notify(OnFindObjectsResponse, header, findObjectsResponse, uri);

            HandleFindObjectsResponse(args);
        }