diff --git a/CryptoExchange.Net/TimeOffsetManager.cs b/CryptoExchange.Net/TimeOffsetManager.cs index 66b9a00..d6165d6 100644 --- a/CryptoExchange.Net/TimeOffsetManager.cs +++ b/CryptoExchange.Net/TimeOffsetManager.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -139,6 +141,26 @@ namespace CryptoExchange.Net /// API name public static TimeSpan? GetSocketOffset(string api) => _lastSocketDelays.TryGetValue(api, out var val) && val.Offset != null ? TimeSpan.FromMilliseconds(val.Offset.Value) : null; + /// + /// Get a dictionary of API/Client name -> time offset for Rest api's + /// + public static Dictionary GetRestOffsets() + { + return _lastRestDelays.ToDictionary( + x => x.Key, + x => (x.Value.Offset == null ? (TimeSpan?)null : TimeSpan.FromMilliseconds(x.Value.Offset.Value))); + } + + /// + /// Get a dictionary of API/Client name -> time offset for Websocket api's + /// + public static Dictionary GetWebsocketOffsets() + { + return _lastSocketDelays.ToDictionary( + x => x.Key, + x => (x.Value.Offset == null ? (TimeSpan?)null : TimeSpan.FromMilliseconds(x.Value.Offset.Value))); + } + /// /// Reset the WebSocket API update timestamp to trigger a new time offset calculation ///