Core direct initialization
- Package:
com.com2usplatform.hiveaxyl.core - Namespaces:
Hive.Axyl.Core,Hive.Axyl.Core.Unity
The APIs on this page are for initializing the SDK with explicitly supplied platform adapters through HiveCore.Initialize(config, adapters, ...), instead of the default HiveBootstrap.Initialize. Most Unity apps initialize with HiveBootstrap.Initialize and do not need them.
PlatformAdapters
- Kind:
class - Namespace:
Hive.Axyl.Core
Bundles engine-specific adapters required for SDK initialization. Immutable after construction; passed to Initialize.
Separates platform implementation from policy configuration (CoreConfig). New adapters (e.g., NativeBridge) can be added here without changing the Initialize signature.
Properties
| Property | Type | Description |
|---|---|---|
Dispatcher | IDispatcher | Main-thread dispatcher for callback delivery. |
Transport | ITransport | Raw platform HTTP transport (e.g., UnityTransport). |
Environment | IAppEnvironment | Platform metadata provider (e.g., UnityAppEnvironment). |
LogSinks | IReadOnlyList<ILogSink> | Log sinks to register with the logger (e.g., UnityConsoleSink). Empty when no engine-specific sinks are needed. |
Constructors
Creates a new PlatformAdapters instance.
| Parameter | Type | Default | Description |
|---|---|---|---|
dispatcher | IDispatcher | — | Main-thread dispatcher. Must not be null. |
transport | ITransport | — | Raw platform transport. Must not be null. |
environment | IAppEnvironment | — | Platform metadata provider. Must not be null. |
logSinks | IReadOnlyList<ILogSink>? | null | Optional log sinks. Null is treated as empty. |
The method throws in the cases below.
ArgumentNullException: Thrown whendispatcher,transport, orenvironmentis null.
IAppEnvironment
- Kind:
interface - Namespace:
Hive.Axyl.Core
Provides read-only access to platform metadata such as engine type, operating system, device model, and application version.
Adapters (e.g., UnityAppEnvironment) implement this interface and register it with the Registry during initialization. Core logic accesses platform information exclusively through this interface — never via engine APIs directly.
All properties return non-null strings. If a value is unavailable on the current platform, the implementation returns an empty string.
Thread safety: implementations must be safe to read from any thread. Property values are expected to be stable after initialization.
Properties
| Property | Type | Description |
|---|---|---|
Engine | string | Engine identifier (e.g., "Unity", "Unreal", "Native"). |
EngineVersion | string | Engine version string (e.g., "2022.3.10f1", "5.4.0"). |
OS | string | Operating system identifier (e.g., "Android", "iOS", "Windows"). |
Environment | string | Execution environment identifier (e.g., "Device", "Editor"). |
OSVersion | string | OS version string (e.g., "14.4.2", "11"). |
DeviceModel | string | Device model name (e.g., "iPhone12,1", "Samsung SM-G991N"). |
AppVersion | string | Application version (e.g., "1.0.0"). |
AppBundleId | string | Package name or bundle identifier (e.g., "com.hive.demo"). |
Language | string | System language code in IETF BCP 47 format (e.g., "ko-KR", "en-US"). Implementations must return "en-US" when the language cannot be determined. |
IDispatcher
- Kind:
interface - Namespace:
Hive.Axyl.Core
Dispatches actions to the main thread. All external API callbacks from Core are executed on the main thread through this interface.
Thread safety: Post and PostDelayed must be safe to call from any thread. This is the primary use case — dispatching from a background thread to the main thread.
Implementations must swallow exceptions thrown by dispatched actions: catch, log at Error, and continue processing remaining items.
Properties
| Property | Type | Description |
|---|---|---|
IsMainThread | bool | Gets a value indicating whether the current thread is the main thread. |
Methods
Post
Posts an action to be executed on the main thread. If already on the main thread, the action may be executed synchronously or queued, depending on the implementation.
| Parameter | Type | Default | Description |
|---|---|---|---|
action | Action | — | The action to execute on the main thread. |
The method throws in the cases below.
ArgumentNullException: Thrown whenactionis null.ObjectDisposedException: Thrown when the dispatcher has been disposed (for disposable implementations).
PostDelayed
Posts an action to be executed on the main thread after the specified delay.
| Parameter | Type | Default | Description |
|---|---|---|---|
action | Action | — | The action to execute on the main thread. |
delay | TimeSpan | — | The delay before the action is posted to the main thread. |
The method throws in the cases below.
ArgumentNullException: Thrown whenactionis null.ArgumentOutOfRangeException: Thrown whendelayis negative.ObjectDisposedException: Thrown when the dispatcher has been disposed (for disposable implementations).
IResolver
- Kind:
interface - Namespace:
Hive.Axyl.Core
Read-only view over registered services, handed to registration factory lambdas so a Capability or Plugin can resolve already-registered core services at build time. It cannot register — apps never register core services.
Methods
Resolve
Resolves the registered service for T.
- Returns:
T
The method throws in the cases below.
RegistrationNotFoundException: Thrown when no service of typeTis registered.
TryResolve
Resolves without throwing; returns false when no service of type T is registered.
| Parameter | Type | Default | Description |
|---|---|---|---|
service | out T? | — |
- Returns:
bool
UnityAppEnvironment
- Kind:
class - Namespace:
Hive.Axyl.Core.Unity - Inherits:
IAppEnvironment
Unity implementation of IAppEnvironment. Wraps Unity engine APIs to provide platform metadata.
Registered by HiveBootstrap during initialization. All properties are safe to read from any thread after construction.
Constructors
Initializes the environment by capturing all platform values. Must be called on the main thread (Unity API requirement).
UnityDispatcher
- Kind:
class - Namespace:
Hive.Axyl.Core - Inherits:
IDispatcher,IDisposable,IDispatcherDisposalObserver
Unity-specific IDispatcher implementation that dispatches actions to the main thread via UnitySynchronizationContext.
This class captures the Unity main-thread UnitySynchronizationContext at construction time and uses it for all dispatch operations. Must be created on the main thread (e.g., from [RuntimeInitializeOnLoadMethod]).
PostDelayed is driven by the player loop, not by a thread timer: the action is re-posted to the UnitySynchronizationContext once per frame until realtimeSinceStartupAsDouble passes the due time. A thread timer (Task.Delay, System.Threading.Timer) never fires on Unity WebGL, which runs on a single thread, so a delay built on one would wait forever there. Consequences of the frame-loop design: the delay is approximate (rounded up to the next frame), it counts real time so it keeps running while Time.timeScale is zero, and it stops advancing while frames stop (background tab, suspended app). It is meant for coarse waits such as retry backoff, not for precise timing.
All dispatched actions are wrapped in try-catch so that one failing action does not prevent remaining queued actions from executing. Exceptions are logged via ILogger at Error when the instance was constructed with a logger; otherwise they are swallowed.
Implements IDisposable to cancel pending delayed actions on shutdown.
Constructors
Initializes a new UnityDispatcher instance. Must be called on the main thread so that the correct UnitySynchronizationContext is captured.
| Parameter | Type | Default | Description |
|---|---|---|---|
logger | ILogger? | null | Optional logger for reporting exceptions thrown by dispatched actions. When null, exceptions are silently swallowed. |
The method throws in the cases below.
InvalidOperationException: Thrown whenCurrentisnull, which indicates this was not called from the main thread.
Methods
Dispose
Drops all pending delayed actions at their next tick and raises Disposed once, so a waiter that armed one can resolve at dispose time instead of a tick that will never come. Actions already queued via Post or already executing are not affected and may still run after disposal. Safe to call multiple times.
Events
Disposed
Raised once, the first time this dispatcher is disposed, so a pending delayed wait can resolve at dispose time instead of waiting for a tick that will never come.
UnityTransport
- Kind:
class - Namespace:
Hive.Axyl.Core.Unity - Inherits:
ITransport
Unity implementation of ITransport that wraps UnityWebRequest.
SendWebRequest must be called on the main thread. This class uses IDispatcher to marshal the call when necessary.
Constructors
Creates a new UnityTransport.
| Parameter | Type | Default | Description |
|---|---|---|---|
dispatcher | IDispatcher | — | Main-thread dispatcher for UnityWebRequest calls. |
logger | ILogger? | null | Optional logger for diagnostic messages. |
The method throws in the cases below.
ArgumentNullException: Thrown whendispatcheris null.