Table of Contents

Class ClientLoginAuthenticator

Namespace
FishMMO.Client
Assembly
FishMMO.Client.dll

FishNet client-side authenticator MonoBehaviour for the FishMMO login flow. Thin adapter over the engine-independent ClientAuthenticatorCore state machine: translates abstract send/disconnect/result callbacks into FishNet broadcasts and connection control, and routes incoming FishNet broadcasts back into the core.

public class ClientLoginAuthenticator : Authenticator
Inheritance
Object
Component
Behaviour
MonoBehaviour
Authenticator
ClientLoginAuthenticator
Inherited Members
Authenticator.Initialized
Authenticator.NetworkManager
Authenticator.OnRemoteConnection(NetworkConnection)
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.MemberwiseClone()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Properties

Client

Reference to the client instance for broadcasting messages.

public Client Client { get; }

Property Value

Client

ConnectionToken

One-time connection token from IPFetch for real-IP recovery on the Login Server. Set before ConnectToServer; null for World/Scene reconnections.

public string ConnectionToken { get; set; }

Property Value

string

HasAuthToken

Returns whether the client has a stored authentication token for World/Scene server connections.

public bool HasAuthToken { get; }

Property Value

bool

LastResultAnsweredTwoFactorCode

Whether the most recent auth result answered a two-factor code this client sent, rather than arriving unasked. Read it inside an OnClientAuthenticationResult handler: it is what tells the two meanings of TwoFactorExpired apart — an answer to a code means the attempts ran out, an unasked one that the prompt's time did.

public bool LastResultAnsweredTwoFactorCode { get; }

Property Value

bool

LastRetryAfterSeconds

Seconds the server said to wait before retrying, from the most recent auth result, or 0. Read it inside an OnClientAuthenticationResult handler, e.g. for TwoFactorLocked.

public int LastRetryAfterSeconds { get; }

Property Value

int

PendingLoginIdentifier

Returns the current login identifier (username or email) if still set. Returns null after credentials are cleared (post-SRP proof or disconnect). Note: .NET strings are immutable and cannot be zeroed, so the identifier remains in managed memory until garbage collected.

public string PendingLoginIdentifier { get; }

Property Value

string

Methods

ClearAuthToken()

Clears the stored authentication token and zeroes its memory. Call on explicit logout or when the token is no longer needed.

public void ClearAuthToken()

InitializeOnce(NetworkManager)

Initializes the authenticator once with the provided network manager. Registers connection state and broadcast handlers.

public override void InitializeOnce(NetworkManager networkManager)

Parameters

networkManager NetworkManager

The network manager instance.

RetryHandshakeAsync()

Resets the authentication state and re-initiates the handshake on the current connection after a randomized jitter delay (0-1s). The jitter prevents all admitted queue clients from sending handshakes simultaneously, which would create a thundering herd at the server's SRP verify channel.

public Task RetryHandshakeAsync()

Returns

Task

Remarks

The connection token from IPFetch is NOT re-sent -- the real IP was already recovered by the initial handshake that triggered queueing.

RevokeAndClearAuthToken()

Best-effort server-side token revocation: if a token is currently stored and the client connection is active, sends a RevokeTokenBroadcast to the LoginServer with the raw token bytes. The server will hash and revoke it via IAuthTokenService. Either way, the local copy is zeroed immediately so the token cannot be reused by this process.

Safe to call when there is no active connection — the broadcast is simply dropped by FishNet and the local token is still cleared.

public Task RevokeAndClearAuthToken()

Returns

Task

SendTotpCode(string)

Encrypts and sends a TOTP code to the server for two-factor verification during login.

public void SendTotpCode(string code)

Parameters

code string

The 6-digit TOTP code from the authenticator app.

SendVerifyCode(string, string)

Encrypts and sends an account verification code to the server on the current connection.

public void SendVerifyCode(string username, string verifyCode)

Parameters

username string

The account username to verify.

verifyCode string

The verification code entered by the user.

SendVerifyCode(string, string, VerificationCodeChannel)

Encrypts and sends a verification code for a specific channel (email or SMS).

public void SendVerifyCode(string username, string verifyCode, VerificationCodeChannel channel)

Parameters

username string

The account username to verify.

verifyCode string

The verification code entered by the user.

channel VerificationCodeChannel

Which channel the code arrived on.

SetClient(Client)

Sets the client instance for broadcasting messages.

public void SetClient(Client client)

Parameters

client Client

The client instance.

SetLoginCredentials(string, string, bool, string, int, RegistrationProfile)

Sets the login credentials for authentication or registration. Returns false if the basic credential format is invalid.

public bool SetLoginCredentials(string username, string password, bool register = false, string email = "", int age = 0, RegistrationProfile profile = null)

Parameters

username string

The username.

password string

The password.

register bool

True to register a new account; false to login.

email string

The email address for multi-factor identification.

age int

The age for multi-factor identification.

profile RegistrationProfile

Optional registration details; registration only.

Returns

bool

true if credentials were accepted; false if rejected.

SetVerificationRequest(string, string, VerificationCodeChannel)

Makes the next connection a verification-only one, which sends this code once the handshake completes instead of signing in. See SetVerificationRequest(string, string, VerificationCodeChannel).

public bool SetVerificationRequest(string username, string verifyCode, VerificationCodeChannel channel)

Parameters

username string
verifyCode string
channel VerificationCodeChannel

Returns

bool

False when the account name or code is not acceptable.

Events

OnAuthenticationResult

Overridden authentication result event (not used on client).

public override event Action<NetworkConnection, bool> OnAuthenticationResult

Event Type

Action<NetworkConnection, bool>

OnClientAuthenticationResult

Client authentication event. Subscribe to receive authentication results from the server.

public event Action<ClientAuthenticationResult> OnClientAuthenticationResult

Event Type

Action<ClientAuthenticationResult>

OnTwoFactorSetupReceived

Fired when the server sends 2FA setup data after account creation. Parameters: otpauth URI (for authenticator app), recovery codes array.

public event Action<string, string[]> OnTwoFactorSetupReceived

Event Type

Action<string, string[]>