Interface IAccountManager<TConnection>
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
TConnectionThe 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
connectionTConnectionThe network connection.
accountNamestringThe account name if found.
Returns
- bool
trueif found; otherwise,false.
GetConnectionAccountData(TConnection, out AccountData)
Gets the account data for a connection.
bool GetConnectionAccountData(TConnection connection, out AccountData accountData)
Parameters
connectionTConnectionThe network connection.
accountDataAccountDataThe account data if found.
Returns
- bool
trueif found; otherwise,false.
GetConnectionByAccountName(string, out TConnection)
Gets the network connection for an account name.
bool GetConnectionByAccountName(string accountName, out TConnection connection)
Parameters
accountNamestringThe account name.
connectionTConnectionThe network connection if found.
Returns
- bool
trueif found; otherwise,false.
GetConnectionEncryptionData(TConnection, out ConnectionEncryptionData)
Gets the encryption data for a connection.
bool GetConnectionEncryptionData(TConnection connection, out ConnectionEncryptionData encryptionData)
Parameters
connectionTConnectionThe network connection.
encryptionDataConnectionEncryptionDataThe encryption data if found.
Returns
- bool
trueif found; otherwise,false.
HasAuthState(TConnection, AuthState)
Checks whether a connection has the specified authentication state.
bool HasAuthState(TConnection connection, AuthState state)
Parameters
connectionTConnectionThe network connection.
stateAuthStateThe auth state to check for.
Returns
- bool
trueif 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
connectionTConnectionThe network connection.
Returns
- bool
trueif auth is in progress (state > Handshake); otherwise,false.
RemoveConnectionAccount(TConnection)
Removes all account mappings for a connection.
void RemoveConnectionAccount(TConnection connection)
Parameters
connectionTConnectionThe 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
connectionTConnectionThe network connection.
publicKeybyte[]The public key for encryption.
Returns
- bool
trueif added;falseif 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
connectionTConnectionThe network connection.
requiredAuthStateThe expected current auth state (compare).
nextAuthStateThe new auth state to set if current matches (swap).
Returns
- bool
trueif 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
connectionTConnectionThe network connection.
requiredAuthStateThe expected current auth state (compare).
nextAuthStateThe new auth state to set if current matches (swap).
onSuccessFunc<AccountData, bool>Callback invoked inside the lock if the transition succeeds. Should return
trueto confirm the operation.
Returns
- bool
trueif the state was advanced and the callback succeeded; otherwise,false.