Initial commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>Time source used by the scenario runtime; override in tests.</summary>
|
||||
public interface IClock
|
||||
{
|
||||
/// <summary>Current UTC time.</summary>
|
||||
DateTimeOffset UtcNow { get; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a stable device identifier for device login.
|
||||
/// The default is <see cref="GuidDeviceIdProvider"/>; games should provide a
|
||||
/// persistent one (Unity uses SystemInfo.deviceUniqueIdentifier).
|
||||
/// </summary>
|
||||
public interface IDeviceIdProvider
|
||||
{
|
||||
/// <summary>Stable identifier of this device/install.</summary>
|
||||
string DeviceId { get; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>Optional scheduler abstraction for delayed plan work.</summary>
|
||||
public interface IPlanScheduler
|
||||
{
|
||||
/// <summary>Completes after the given delay.</summary>
|
||||
Task ScheduleAsync(TimeSpan delay, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Persists serialized scenario-run state between app launches.
|
||||
/// Null by default (no persistence).
|
||||
/// </summary>
|
||||
public interface IPlanStateStore
|
||||
{
|
||||
/// <summary>Serialized state blob, or null when empty.</summary>
|
||||
string? State { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Low-level realtime (websocket) transport. There is no default implementation;
|
||||
/// provide one through <see cref="IRealtimeTransportFactory"/> (Unity ships its own).
|
||||
/// </summary>
|
||||
public interface IRealtimeTransport
|
||||
{
|
||||
/// <summary>Raised when the connection closes.</summary>
|
||||
event Action Closed;
|
||||
|
||||
/// <summary>Raised for every incoming message.</summary>
|
||||
event Action<ArraySegment<byte>> Received;
|
||||
|
||||
/// <summary>Raised on transport errors.</summary>
|
||||
event Action<Exception> Error;
|
||||
|
||||
/// <summary>True while the connection is open.</summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
/// <summary>Opens the connection, giving up after <paramref name="timeout"/>.</summary>
|
||||
Task ConnectAsync(Uri uri, TimeSpan timeout, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>Sends one message.</summary>
|
||||
Task SendAsync(ArraySegment<byte> data, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>Closes the connection.</summary>
|
||||
Task CloseAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>Pumps time-dependent logic; call every frame.</summary>
|
||||
void Update(float deltaTime);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>Creates realtime transports on demand (one per connection).</summary>
|
||||
public interface IRealtimeTransportFactory
|
||||
{
|
||||
/// <summary>Creates a new, unconnected transport.</summary>
|
||||
IRealtimeTransport Create();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>Severity of an SDK log message.</summary>
|
||||
public enum RudderLogLevel
|
||||
{
|
||||
/// <summary>Verbose diagnostics.</summary>
|
||||
Debug,
|
||||
|
||||
/// <summary>Normal operational messages.</summary>
|
||||
Info,
|
||||
|
||||
/// <summary>Recoverable problems worth investigating.</summary>
|
||||
Warning,
|
||||
|
||||
/// <summary>Failures that broke an operation.</summary>
|
||||
Error
|
||||
}
|
||||
|
||||
/// <summary>Optional sink for SDK diagnostics. Null by default (silent).</summary>
|
||||
public interface IRudderLogger
|
||||
{
|
||||
/// <summary>Writes one message at the given severity.</summary>
|
||||
void Log(RudderLogLevel level, string message);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// HTTP transport used by the SDK for every API call. Implementations serialize
|
||||
/// the request as JSON, attach the bearer token, and map non-success HTTP
|
||||
/// statuses to <see cref="RudderApiException"/> subclasses
|
||||
/// (401 → <see cref="RudderAuthException"/>).
|
||||
/// </summary>
|
||||
public interface IRudderTransport
|
||||
{
|
||||
/// <summary>
|
||||
/// Sends one API request and deserializes the JSON response.
|
||||
/// </summary>
|
||||
/// <param name="method">HTTP method (GET, POST, PUT, DELETE).</param>
|
||||
/// <param name="path">Absolute path starting at the API root, e.g. /sdk/v1/player/information.</param>
|
||||
/// <param name="request">Request body DTO, or null for bodyless requests.</param>
|
||||
/// <param name="accessToken">Current access token to send as a Bearer header, or null.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
Task<TResponse> SendAsync<TRequest, TResponse>(
|
||||
string method,
|
||||
string path,
|
||||
TRequest? request,
|
||||
string? accessToken,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Persists the session token pair. The default is <see cref="InMemoryTokenStore"/>;
|
||||
/// games should provide a durable implementation (player prefs, keychain, ...).
|
||||
/// </summary>
|
||||
public interface ITokenStore
|
||||
{
|
||||
/// <summary>Returns the current access token, or null when signed out.</summary>
|
||||
string? GetAccessToken();
|
||||
|
||||
/// <summary>Returns the current refresh token, or null when signed out.</summary>
|
||||
string? GetRefreshToken();
|
||||
|
||||
/// <summary>Stores a fresh token pair.</summary>
|
||||
void SaveTokens(string accessToken, string refreshToken);
|
||||
|
||||
/// <summary>Drops both tokens (logout / session expiry).</summary>
|
||||
void Clear();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RudderSdk.Core.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Uploads raw bytes to pre-signed UGC URLs. Optional; required only by
|
||||
/// <see cref="UgcService.UploadAsync"/>.
|
||||
/// </summary>
|
||||
public interface IUploadTransport
|
||||
{
|
||||
/// <summary>PUTs the payload to the pre-signed URL with the given content type.</summary>
|
||||
Task PutAsync(string url, byte[] data, string contentType, CancellationToken cancellationToken = default);
|
||||
}
|
||||
Reference in New Issue
Block a user