public virtual MessageRouterResult AddPendingRequest(Party party) { MessageRouterResult result = new MessageRouterResult() { ConversationClientParty = party }; if (party != null) { if (PendingRequests.Contains(party)) { result.Type = MessageRouterResultType.EngagementAlreadyInitiated; } else { PendingRequests.Add(party); result.Type = MessageRouterResultType.EngagementInitiated; } } else { result.Type = MessageRouterResultType.Error; result.ErrorMessage = "The given party instance is null"; } return(result); }
public async Task Init() { PendingRequests.Clear(); var id = int.Parse(JWTService.DecodeJWT()); var search = new Model.Requests.RequestSearchRequest { ShowInactive = false, StatusId = (int)Models.Status.Pending }; var requestList = await _requestService.GetAll <List <Request> >(search); foreach (var request in requestList) { var address = await _addressService.GetById <Address>(request.DeliveryAddress); var country = await _countryService.GetById <Country>((int)address.CountryId); var newRequest = new ClientDashboardRequest { Address = country.Name + ", " + address.ZipCode + ", " + address.City, Date = request.Date, Price = request.Price, RequestId = request.RequestId }; IsPendingVisible = true; IsPendingMessageVisible = false; PendingRequests.Add(newRequest); } PendingHeight = PendingRequests.Count * 36; }
internal static void Request(MarketerDataRequest marketerDataRequest) { var cachedType = CachedRequests.FirstOrDefault(x => x.RawMarketType.id == marketerDataRequest.Id.ToString() && x.Region == marketerDataRequest.Region && x.SolarSystem == marketerDataRequest.SolarSystem); if (cachedType != null) { if (cachedType != null) { var difference = marketerDataRequest.Timestamp - cachedType.Timestamp; if (difference.TotalMinutes > 30) { CachedRequests.Remove(cachedType); } else { return; } } } var pendingRequest = PendingRequests.FirstOrDefault(x => x.Id == marketerDataRequest.Id && x.Region == marketerDataRequest.Region && x.SolarSystem == marketerDataRequest.SolarSystem); if (pendingRequest != null) { return; } PendingRequests.Add(marketerDataRequest); if (PendingRequests.Count(x => x.Region == marketerDataRequest.Region && x.SolarSystem == marketerDataRequest.SolarSystem) >= 200) { Request(marketerDataRequest.Region, marketerDataRequest.SolarSystem); } }
public void RequestJoin(string playerID) { PendingRequests.Add(playerID); string message = string.Format("{0} requests permission to join the group.", MySockets.Server.GetAUser(playerID).Player.FullName); MySockets.Server.GetAUser(playerID).MessageHandler("Your request to join the group has been sent to the group leader."); InformGroupLeader(message); }
/// <summary>Performs a HTTP GET request. </summary> /// <param name="request">The <see cref="HttpGetRequest"/>. </param> /// <param name="token">The <see cref="CancellationToken"/>. </param> /// <param name="progress">The <see cref="IProgress{T}"/>. </param> /// <returns>The <see cref="HttpResponse"/>. </returns> public static async Task <HttpResponse> GetAsync(HttpGetRequest request, CancellationToken token, IProgress <HttpProgress> progress = null) { var uri = GetQueryString(request, request.Query); var handler = CreateHandler(request, uri); using (var client = CreateClient(request, handler)) { var result = new HttpResponse(request); result.HttpClient = client; lock (PendingRequests) PendingRequests.Add(result); try { var response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead, token); await CreateResponse(result, uri, request, handler, response, token, progress); result.HttpStatusCode = response.StatusCode; if (!response.IsSuccessStatusCode) { result.Exception = new HttpStatusException(response.StatusCode.ToString()) { Result = result, HttpStatusCode = result.HttpStatusCode } } ; } catch (Exception exception) { if (result.Exception == null) { result.Exception = exception; throw; } } finally { lock (PendingRequests) PendingRequests.Remove(result); } if (result.Exception != null) { throw result.Exception; } return(result); } }
// Could be expanded to handle POST commands in addition to GET (which is implemented here) public int SendRequest(string url, bool silent = false, float timeoutSecs = Single.MaxValue, bool lifelineRequest = false) { if (!silent) { Debug.Log("Sending request: " + url); } var id = NextRequestId++; var request = new PendingRequest(id, new WWW(url), silent, timeoutSecs, lifelineRequest); PendingRequests.Add(request); IsWaiting = true; return(id); }
internal static void RequestAll() { var cachedRequests = CachedRequests.ToList(); foreach (var cachedType in cachedRequests) { MarketerDataRequest request = null; if (cachedType != null) { if (cachedType != null) { var difference = DateTime.Now - cachedType.Timestamp; if (difference.TotalMinutes > 30) { request = new MarketerDataRequest(cachedType.Id, cachedType.Region, cachedType.SolarSystem); CachedRequests.Remove(cachedType); } else { return; } } } var pendingRequest = PendingRequests.FirstOrDefault(x => x.Id == request.Id && x.Region == request.Region && x.SolarSystem == request.SolarSystem); if (pendingRequest != null) { return; } PendingRequests.Add(request); if (PendingRequests.Count(x => x.Region == request.Region && x.SolarSystem == request.SolarSystem) >= 200) { Request(request.Region, request.SolarSystem); } } ProcessPendingRequests(); }
public virtual MessageRouterResult AddPendingRequest(Party party) { MessageRouterResult result = new MessageRouterResult() { ConversationClientParty = party }; if (party != null) { if (PendingRequests.Contains(party)) { result.Type = MessageRouterResultType.ConnectionAlreadyRequested; } else { if (!AggregationParties.Any() && Convert.ToBoolean(ConfigurationManager.AppSettings[MessageRouterManager.RejectPendingRequestIfNoAggregationChannelAppSetting])) { result.Type = MessageRouterResultType.NoAgentsAvailable; } else { if (party is PartyWithTimestamps) { (party as PartyWithTimestamps).ConnectionRequestTime = DateTime.UtcNow; } PendingRequests.Add(party); result.Type = MessageRouterResultType.ConnectionRequested; } } } else { result.Type = MessageRouterResultType.Error; result.ErrorMessage = "The given party instance is null"; } return(result); }
/// <summary> /// Performs a HTTP POST request. /// </summary> /// <param name="request">The <see cref="HttpPostRequest"/>. </param> /// <param name="token">The <see cref="CancellationToken"/>. </param> /// <param name="progress">The <see cref="IProgress{T}"/>. </param> /// <returns>The <see cref="HttpResponse"/>. </returns> public static async Task <HttpResponse> PostAsync(HttpPostRequest request, CancellationToken token, IProgress <HttpProgress> progress = null) { var uri = GetQueryString(request, request.Query); var handler = CreateHandler(request, uri); using (var client = CreateClient(request, handler)) { var result = new HttpResponse(request); result.HttpClient = client; lock (PendingRequests) PendingRequests.Add(result); try { HttpContent content = null; if (request.RawData != null) { content = new ByteArrayContent(request.RawData); } else if (request.Files == null || request.Files.Count == 0) { content = new ByteArrayContent(request.Encoding.GetBytes(GetQueryString(request.Data))); } else { var multipartContent = new MultipartFormDataContent(); foreach (var pair in request.Data) { multipartContent.Add(new ByteArrayContent(request.Encoding.GetBytes(pair.Value)), pair.Key); } foreach (var file in request.Files) { try { var byteContent = new ByteArrayContent(await file.Stream.ReadToEndAsync(0, token, null)); byteContent.Headers.ContentType = new MediaTypeHeaderValue( file.ContentType ?? "application/octet-stream"); multipartContent.Add(byteContent, file.Name, file.Filename); } finally { if (file.CloseStream) { file.Stream.Dispose(); } } } content = multipartContent; } var response = await client.PostAsync(uri, content, token); await CreateResponse(result, uri, request, handler, response, token, progress); result.HttpStatusCode = response.StatusCode; if (!response.IsSuccessStatusCode) { result.Exception = new HttpStatusException(response.StatusCode.ToString()) { Result = result, HttpStatusCode = result.HttpStatusCode } } ; } catch (Exception ex) { if (result.Exception == null) { result.Exception = ex; throw; } } finally { lock (PendingRequests) PendingRequests.Remove(result); } if (result.Exception != null) { throw result.Exception; } return(result); } }
public void AddRequest(PendingRequest request) { PendingRequests.Add(request); }
protected override bool ExecuteAddPendingRequest(Party requestorParty) { PendingRequests.Add(requestorParty); return(true); }