Class ServiceHttpClient
Outbound HTTP client for backend services (Session/Account/OAuth/JWKS). The game server runs no
HTTP listener: every HTTP touchpoint is an outbound call. Mirrors the Java
ServiceHttpClientFactory + service-client plumbing: Bearer auth, JSON bodies, a 30s default
timeout, and a HytaleServer/<version> user agent. Shard.Auth builds typed
service calls on top of this.
JSON uses JsonTypeInfo<T> so it stays NativeAOT-safe.
public sealed class ServiceHttpClient : IDisposable
- Inheritance
-
ServiceHttpClient
- Implements
- Inherited Members
Constructors
ServiceHttpClient(string, TimeSpan?, HttpMessageHandler?)
public ServiceHttpClient(string userAgent, TimeSpan? timeout = null, HttpMessageHandler? handler = null)
Parameters
userAgentstringtimeoutTimeSpan?handlerHttpMessageHandler
Methods
DeleteAsync(string, string?, CancellationToken)
public Task DeleteAsync(string url, string? bearer = null, CancellationToken ct = default)
Parameters
urlstringbearerstringctCancellationToken
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetJsonAsync<TResponse>(string, JsonTypeInfo<TResponse>, string?, CancellationToken)
public Task<TResponse?> GetJsonAsync<TResponse>(string url, JsonTypeInfo<TResponse> responseInfo, string? bearer = null, CancellationToken ct = default)
Parameters
urlstringresponseInfoJsonTypeInfo<TResponse>bearerstringctCancellationToken
Returns
- Task<TResponse>
Type Parameters
TResponse
PostFormAsync<TResponse>(string, IEnumerable<KeyValuePair<string, string>>, JsonTypeInfo<TResponse>, string?, CancellationToken)
POST a form-encoded body and read the JSON response. Does NOT throw on non-success status, since OAuth endpoints return JSON error bodies (e.g. authorization_pending) with 4xx.
public Task<TResponse?> PostFormAsync<TResponse>(string url, IEnumerable<KeyValuePair<string, string>> form, JsonTypeInfo<TResponse> responseInfo, string? bearer = null, CancellationToken ct = default)
Parameters
urlstringformIEnumerable<KeyValuePair<string, string>>responseInfoJsonTypeInfo<TResponse>bearerstringctCancellationToken
Returns
- Task<TResponse>
Type Parameters
TResponse
PostJsonAsync<TRequest, TResponse>(string, TRequest, JsonTypeInfo<TRequest>, JsonTypeInfo<TResponse>, string?, CancellationToken)
public Task<TResponse?> PostJsonAsync<TRequest, TResponse>(string url, TRequest body, JsonTypeInfo<TRequest> requestInfo, JsonTypeInfo<TResponse> responseInfo, string? bearer = null, CancellationToken ct = default)
Parameters
urlstringbodyTRequestrequestInfoJsonTypeInfo<TRequest>responseInfoJsonTypeInfo<TResponse>bearerstringctCancellationToken
Returns
- Task<TResponse>
Type Parameters
TRequestTResponse