/// <summary> /// Send new session requests for all sessions where we currently don't have a multiplicity configuration. /// </summary> /// <param name="context">The state context.</param> /// <returns>The last status response received.</returns> private IStatusResponse SendNewSessionRequests(IBeaconSendingContext context) { IStatusResponse statusResponse = null; var notConfiguredSessions = context.GetAllNotConfiguredSessions(); foreach (var session in notConfiguredSessions) { if (!session.CanSendNewSessionRequest) { // already exceeded the maximum number of session requests, disable any further data collecting session.DisableCapture(); continue; } statusResponse = context.GetHttpClient().SendNewSessionRequest(context); if (BeaconSendingResponseUtil.IsSuccessfulResponse(statusResponse)) { var updatedAttributes = context.UpdateFrom(statusResponse); var newConfiguration = ServerConfiguration.From(updatedAttributes); session.UpdateServerConfiguration(newConfiguration); } else if (BeaconSendingResponseUtil.IsTooManyRequestsResponse(statusResponse)) { // server is currently overloaded, return immediately break; } else { // any other unsuccessful response session.DecreaseNumRemainingSessionRequests(); } } return(statusResponse); }