Table of Contents

Interface IAccountManager<TConnection>

Namespace
FishMMO.Auth.Core
Assembly
FishMMO-ServerAuth.dll

Base interface for managing account and connection data shared by all server types. Contains encryption, account lookup, authentication state machine, and lifecycle methods common to both SRP-based (Login) and token-based (World/Scene) authentication flows.

public interface IAccountManager<TConnection>

Type Parameters

TConnection

The type representing a network connection.

Methods

Clear()

Zeroes all sensitive key material and clears all stored account and connection data.

void Clear()

GetAccountNameByConnection(TConnection, out string)

Gets the account name for a connection.

bool GetAccountNameByConnection(TConnection connection, out string accountName)

Parameters

connection TConnection

The network connection.

accountName string

The account name if found.

Returns

bool

true if found; otherwise, false.

GetConnectionAccountData(TConnection, out AccountData)

Gets the account data for a connection.

bool GetConnectionAccountData(TConnection connection, out AccountData accountData)

Parameters

connection TConnection

The network connection.

accountData AccountData

The account data if found.

Returns

bool

true if found; otherwise, false.

GetConnectionByAccountName(string, out TConnection)

Gets the network connection for an account name.

bool GetConnectionByAccountName(string accountName, out TConnection connection)

Parameters

accountName string

The account name.

connection TConnection

The network connection if found.

Returns

bool

true if found; otherwise, false.

GetConnectionEncryptionData(TConnection, out ConnectionEncryptionData)

Gets the encryption data for a connection.

bool GetConnectionEncryptionData(TConnection connection, out ConnectionEncryptionData encryptionData)

Parameters

connection TConnection

The network connection.

encryptionData ConnectionEncryptionData

The encryption data if found.

Returns

bool

true if found; otherwise, false.

HasAuthState(TConnection, AuthState)

Checks whether a connection has the specified authentication state.

bool HasAuthState(TConnection connection, AuthState state)

Parameters

connection TConnection

The network connection.

state AuthState

The auth state to check for.

Returns

bool

true if the connection has exactly the given state; otherwise, false.

IsAuthInProgress(TConnection)

Checks whether a connection has progressed beyond Handshake (i.e., an authentication flow is actively in progress). Used by handshake handlers to reject repeated handshakes during auth.

bool IsAuthInProgress(TConnection connection)

Parameters

connection TConnection

The network connection.

Returns

bool

true if auth is in progress (state > Handshake); otherwise, false.

RemoveConnectionAccount(TConnection)

Removes all account mappings for a connection.

void RemoveConnectionAccount(TConnection connection)

Parameters

connection TConnection

The network connection.

TryAddConnectionEncryptionData(TConnection, byte[])

Adds encryption data for a connection and creates initial AccountData with Handshake. Uses try-add semantics: returns false if the connection already has encryption data.

bool TryAddConnectionEncryptionData(TConnection connection, byte[] publicKey)

Parameters

connection TConnection

The network connection.

publicKey byte[]

The public key for encryption.

Returns

bool

true if added; false if encryption data already existed.

TryAdvanceAuthState(TConnection, AuthState, AuthState)

Atomically advances the authentication state for a connection. Returns false if the current state does not match required.

bool TryAdvanceAuthState(TConnection connection, AuthState required, AuthState next)

Parameters

connection TConnection

The network connection.

required AuthState

The expected current auth state (compare).

next AuthState

The new auth state to set if current matches (swap).

Returns

bool

true if the state was advanced; otherwise, false.

TryAdvanceAuthState(TConnection, AuthState, AuthState, Func<AccountData, bool>)

Atomically advances the authentication state for a connection and invokes a callback on success. The callback runs inside the lock and must not block or re-enter the AccountManager.

bool TryAdvanceAuthState(TConnection connection, AuthState required, AuthState next, Func<AccountData, bool> onSuccess)

Parameters

connection TConnection

The network connection.

required AuthState

The expected current auth state (compare).

next AuthState

The new auth state to set if current matches (swap).

onSuccess Func<AccountData, bool>

Callback invoked inside the lock if the transition succeeds. Should return true to confirm the operation.

Returns

bool

true if the state was advanced and the callback succeeded; otherwise, false.