private async Task SendBatchRequestAsync()

in FirebaseAdmin/FirebaseAdmin/Messaging/FirebaseMessagingClient.cs [195:232]


        private async Task<BatchResponse> SendBatchRequestAsync(
            IEnumerable<Message> messages,
            bool dryRun,
            CancellationToken cancellationToken)
        {
            var responses = new List<SendResponse>();

            var batch = this.CreateBatchRequest(
                messages,
                dryRun,
                (content, error, index, message) =>
                {
                    SendResponse sendResponse;
                    if (error != null)
                    {
                        var json = (error as ContentRetainingRequestError).Content;
                        var exception = MessagingErrorHandler.Instance.HandleHttpErrorResponse(
                            message, json);
                        sendResponse = SendResponse.FromException(exception);
                    }
                    else if (content != null)
                    {
                        sendResponse = SendResponse.FromMessageId(content.Name);
                    }
                    else
                    {
                        var exception = new FirebaseMessagingException(
                            ErrorCode.Unknown,
                            $"Unexpected batch response. Response status code: {message.StatusCode}.");
                        sendResponse = SendResponse.FromException(exception);
                    }

                    responses.Add(sendResponse);
                });

            await batch.ExecuteAsync(cancellationToken).ConfigureAwait(false);
            return new BatchResponse(responses);
        }