1+ // --------------------------------------------------------------------------------------------------------------------
2+ // <copyright file="INetworkRequestManager.cs" company="MADE Apps">
3+ // Copyright (c) MADE Apps.
4+ // </copyright>
5+ // <summary>
6+ // Defines an interface for a network request manager.
7+ // </summary>
8+ // --------------------------------------------------------------------------------------------------------------------
9+
10+ namespace MADE . App . Networking
11+ {
12+ using System ;
13+ using System . Collections . Concurrent ;
14+
15+ using MADE . App . Networking . Requests ;
16+
17+ /// <summary>
18+ /// Defines an interface for a network request manager.
19+ /// </summary>
20+ public interface INetworkRequestManager
21+ {
22+ /// <summary>
23+ /// Gets the current queue of network requests.
24+ /// </summary>
25+ ConcurrentDictionary < string , NetworkRequestCallback > CurrentQueue { get ; }
26+
27+ /// <summary>
28+ /// Starts the manager processing the queue of network requests at a default time period of 1 minute.
29+ /// </summary>
30+ void Start ( ) ;
31+
32+ /// <summary>
33+ /// Starts the manager processing the queue of network requests.
34+ /// </summary>
35+ /// <param name="processPeriod">
36+ /// The time period between each process of the queue.
37+ /// </param>
38+ void Start ( TimeSpan processPeriod ) ;
39+
40+ /// <summary>
41+ /// Stops the processing of the network manager queues.
42+ /// </summary>
43+ void Stop ( ) ;
44+
45+ /// <summary>
46+ /// Adds or updates a network request in the queue.
47+ /// </summary>
48+ /// <typeparam name="TRequest">
49+ /// The type of network request.
50+ /// </typeparam>
51+ /// <typeparam name="TResponse">
52+ /// The expected response type.
53+ /// </typeparam>
54+ /// <param name="request">
55+ /// The network request to execute.
56+ /// </param>
57+ /// <param name="successCallback">
58+ /// The action to execute when receiving a successful response.
59+ /// </param>
60+ void AddOrUpdate < TRequest , TResponse > ( TRequest request , Action < TResponse > successCallback )
61+ where TRequest : NetworkRequest ;
62+
63+ /// <summary>
64+ /// Adds or updates a network request in the queue.
65+ /// </summary>
66+ /// <typeparam name="TRequest">
67+ /// The type of network request.
68+ /// </typeparam>
69+ /// <typeparam name="TResponse">
70+ /// The expected response type.
71+ /// </typeparam>
72+ /// <typeparam name="TErrorResponse">
73+ /// The expected error response type.
74+ /// </typeparam>
75+ /// <param name="request">
76+ /// The network request to execute.
77+ /// </param>
78+ /// <param name="successCallback">
79+ /// The action to execute when receiving a successful response.
80+ /// </param>
81+ /// <param name="errorCallback">
82+ /// The action to execute when receiving an error response.
83+ /// </param>
84+ void AddOrUpdate < TRequest , TResponse , TErrorResponse > (
85+ TRequest request ,
86+ Action < TResponse > successCallback ,
87+ Action < TErrorResponse > errorCallback )
88+ where TRequest : NetworkRequest ;
89+
90+ /// <summary>
91+ /// Processes the current queue of network requests.
92+ /// </summary>
93+ void ProcessCurrentQueue ( ) ;
94+ }
95+ }
0 commit comments