Class ClientLoginAuthenticator
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
-
ObjectComponentBehaviourMonoBehaviourAuthenticatorClientLoginAuthenticator
- Inherited Members
-
Authenticator.InitializedAuthenticator.NetworkManagerAuthenticator.OnRemoteConnection(NetworkConnection)MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.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.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.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.nameObject.hideFlags
Properties
Client
Reference to the client instance for broadcasting messages.
public Client Client { get; }
Property Value
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
HasAuthToken
Returns whether the client has a stored authentication token for World/Scene server connections.
public bool HasAuthToken { get; }
Property Value
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
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
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
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
networkManagerNetworkManagerThe 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
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
SendTotpCode(string)
Encrypts and sends a TOTP code to the server for two-factor verification during login.
public void SendTotpCode(string code)
Parameters
codestringThe 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
usernamestringThe account username to verify.
verifyCodestringThe 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
usernamestringThe account username to verify.
verifyCodestringThe verification code entered by the user.
channelVerificationCodeChannelWhich channel the code arrived on.
SetClient(Client)
Sets the client instance for broadcasting messages.
public void SetClient(Client client)
Parameters
clientClientThe 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
usernamestringThe username.
passwordstringThe password.
registerboolTrue to register a new account; false to login.
emailstringThe email address for multi-factor identification.
ageintThe age for multi-factor identification.
profileRegistrationProfileOptional registration details; registration only.
Returns
- bool
trueif credentials were accepted;falseif 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
usernamestringverifyCodestringchannelVerificationCodeChannel
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
OnClientAuthenticationResult
Client authentication event. Subscribe to receive authentication results from the server.
public event Action<ClientAuthenticationResult> OnClientAuthenticationResult
Event Type
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