Class NetworkRequestManager
- Namespace
- MADE.Networking.Http
- Assembly
- MADE.Networking.dll
Defines a manager for executing queued network requests.
public sealed class NetworkRequestManager : INetworkRequestManager, IDisposable
- Inheritance
-
NetworkRequestManager
- Implements
- Inherited Members
- Extension Methods
Constructors
NetworkRequestManager()
Initializes a new instance of the NetworkRequestManager class.
public NetworkRequestManager()
Properties
CurrentQueue
Gets the current queue of network requests.
public ConcurrentDictionary<string, NetworkRequestCallback> CurrentQueue { get; }
Property Value
Methods
AddOrUpdate<TRequest, TResponse>(TRequest, Action<TResponse>)
Adds or updates a network request in the queue.
public void AddOrUpdate<TRequest, TResponse>(TRequest request, Action<TResponse> successCallback) where TRequest : NetworkRequest
Parameters
requestTRequestThe network request to execute.
successCallbackAction<TResponse>The action to execute when receiving a successful response.
Type Parameters
TRequestThe type of network request.
TResponseThe expected response type.
Exceptions
- Exception
The
successCallbackthrows an exception acquiring method info.- OverflowException
The CurrentQueue already contains the maximum number of elements (MaxValue).
AddOrUpdate<TRequest, TResponse, TErrorResponse>(TRequest, Action<TResponse>, Action<TErrorResponse>?)
Adds or updates a network request in the queue.
public void AddOrUpdate<TRequest, TResponse, TErrorResponse>(TRequest request, Action<TResponse> successCallback, Action<TErrorResponse>? errorCallback) where TRequest : NetworkRequest
Parameters
requestTRequestThe network request to execute.
successCallbackAction<TResponse>The action to execute when receiving a successful response.
errorCallbackAction<TErrorResponse>The action to execute when receiving an error response.
Type Parameters
TRequestThe type of network request.
TResponseThe expected response type.
TErrorResponseThe expected error response type.
Exceptions
- Exception
The
successCallbackorerrorCallbackthrows an exception acquiring method info.- OverflowException
The CurrentQueue already contains the maximum number of elements (MaxValue).
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
ProcessCurrentQueueAsync()
Processes the current queue of network requests.
public Task ProcessCurrentQueueAsync()
Returns
- Task
An asynchronous operation.
Remove(INetworkRequest)
Removes a network request from the queue.
If the request is no longer in the queue, this method does nothing.
public void Remove(INetworkRequest request)
Parameters
requestINetworkRequestThe request to remove from the queue.
RemoveByKey(string)
Removes a network request from the queue by the registered key identifier.
If the request is no longer in the queue, this method does nothing.
public void RemoveByKey(string key)
Parameters
keystringThe key corresponding to the network request to remove from the queue.
Start()
Starts the manager processing the queue of network requests at a default time period of 1 minute.
public void Start()
Start(TimeSpan)
Starts the manager processing the queue of network requests.
public void Start(TimeSpan processPeriod)
Parameters
processPeriodTimeSpanThe time period between each process of the queue.
Stop()
Stops the processing of the network manager queues.
public void Stop()