Skip to content

feat: Add connection state check method#473

Merged
kirre-bylund merged 2 commits into
devfrom
feat/1574-connection-state-check
Jun 9, 2026
Merged

feat: Add connection state check method#473
kirre-bylund merged 2 commits into
devfrom
feat/1574-connection-state-check

Conversation

@kirre-bylund

Copy link
Copy Markdown
Contributor

Summary

Adds CheckConnectionStatus — a single public method that reports the current connection and session state for a player without requiring the developer to interpret raw HTTP status codes.

Implementation of https://github.com/lootlocker/index/issues/1574 for the Unity SDK

How it works

  1. Fast local checks (no network call):

    • SDK not initialized → NotInitialized
    • No session token in local state → NotSignedIn
    • Application.internetReachability == NotReachableNoConnection
  2. Live check (ping):

    • 200 → SignedInAndConnected (+ ServerTime populated)
    • 5xx → ServerError
    • 401 or 403 → calls GetPlayerBanStatus to disambiguate:
      • is_banned == trueBanned (+ BanDetails populated)
      • otherwise → SessionExpired
    • No response / timeout / status 0 → NoConnection

Both 401 and 403 trigger the ban-status check because allowTokenRefresh=true can cause a ban-related 403 to auto-refresh, fail, and surface as a synthesized 401.

The method never attempts token refresh — it reports raw state so the developer can decide how to recover.

API

LootLockerSDKManager.CheckConnectionStatus(response =>
{
    switch (response.State)
    {
        case LootLockerConnectionState.SignedInAndConnected: /* all good */ break;
        case LootLockerConnectionState.NotSignedIn:         /* prompt login */ break;
        case LootLockerConnectionState.SessionExpired:      /* refresh or re-auth */ break;
        case LootLockerConnectionState.Banned:              /* show response.BanDetails */ break;
        case LootLockerConnectionState.NoConnection:        /* show offline UI */ break;
        case LootLockerConnectionState.ServerError:         /* retry later */ break;
        case LootLockerConnectionState.NotInitialized:      /* init SDK first */ break;
    }
}, forPlayerWithUlid: null); // optional, defaults to active player

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new public API (LootLockerSDKManager.CheckConnectionStatus) to report a player’s connection/session state (initialized, signed in, banned, no connection, etc.) without requiring developers to interpret HTTP status codes directly.

Changes:

  • Introduces LootLockerConnectionState and LootLockerConnectionStateResponse response models.
  • Adds a new LootLockerAPIManager.CheckConnectionStatus request implementation using ping (+ ban status disambiguation for 401/403).
  • Adds the public LootLockerSDKManager.CheckConnectionStatus facade with fast local checks (initialized/session token/internet reachability) before the live ping.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
Runtime/Game/Requests/MiscRequests.cs Adds the connection state enum/response model and the underlying ping + ban-status request logic.
Runtime/Game/LootLockerSDKManager.cs Adds the public CheckConnectionStatus API and local preflight checks before calling the request layer.

Comment thread Runtime/Game/Requests/MiscRequests.cs Outdated
Comment thread Runtime/Game/Requests/MiscRequests.cs Outdated
Comment thread Runtime/Game/LootLockerSDKManager.cs Outdated

@JohannesLoot JohannesLoot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff!
Merge away!

@kirre-bylund kirre-bylund merged commit 871953b into dev Jun 9, 2026
58 checks passed
@kirre-bylund kirre-bylund deleted the feat/1574-connection-state-check branch June 9, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants