Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.

Commit

Permalink
Mirror 41
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek-R-S committed Jun 14, 2021
1 parent 68ad564 commit f988f2d
Show file tree
Hide file tree
Showing 714 changed files with 3,290 additions and 11,536 deletions.
6 changes: 3 additions & 3 deletions UnityProject/Assets/Mirror/Authenticators.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 17 additions & 10 deletions UnityProject/Assets/Mirror/Authenticators/BasicAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class BasicAuthenticator : NetworkAuthenticator
public string username;
public string password;

// this is set if authentication fails to prevent garbage AuthRequestMessage spam
bool ServerAuthFailed;

#region Messages

public struct AuthRequestMessage : NetworkMessage
Expand Down Expand Up @@ -101,7 +104,13 @@ public void OnAuthRequestMessage(NetworkConnection conn, AuthRequestMessage msg)
conn.isAuthenticated = false;

// disconnect the client after 1 second so that response message gets delivered
StartCoroutine(DelayedDisconnect(conn, 1));
if (!ServerAuthFailed)
{
// set this false so this coroutine can only be started once
ServerAuthFailed = true;

StartCoroutine(DelayedDisconnect(conn, 1));
}
}
}

Expand Down Expand Up @@ -140,22 +149,23 @@ public override void OnStopClient()
/// <summary>
/// Called on client from OnClientAuthenticateInternal when a client needs to authenticate
/// </summary>
/// <param name="conn">Connection of the client.</param>
public override void OnClientAuthenticate(NetworkConnection conn)
public override void OnClientAuthenticate()
{
AuthRequestMessage authRequestMessage = new AuthRequestMessage
{
authUsername = username,
authPassword = password
};

conn.Send(authRequestMessage);
NetworkClient.connection.Send(authRequestMessage);
}

[Obsolete("Call OnAuthResponseMessage without the NetworkConnection parameter. It always points to NetworkClient.connection anyway.")]
public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg) => OnAuthResponseMessage(msg);

/// <summary>
/// Called on client when the server's AuthResponseMessage arrives
/// </summary>
/// <param name="conn">Connection to client.</param>
/// <param name="msg">The message payload</param>
public void OnAuthResponseMessage(AuthResponseMessage msg)
{
Expand All @@ -164,20 +174,17 @@ public void OnAuthResponseMessage(AuthResponseMessage msg)
// Debug.LogFormat(LogType.Log, "Authentication Response: {0}", msg.message);

// Authentication has been accepted
ClientAccept(NetworkClient.connection);
ClientAccept();
}
else
{
Debug.LogError($"Authentication Response: {msg.message}");

// Authentication has been rejected
ClientReject(NetworkClient.connection);
ClientReject();
}
}

[Obsolete("Call OnAuthResponseMessage without the NetworkConnection parameter. It always points to NetworkClient.connection anyway.")]
public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg) => OnAuthResponseMessage(msg);

#endregion
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,21 @@ public override void OnServerAuthenticate(NetworkConnection conn)
StartCoroutine(BeginAuthentication(conn));
}

public override void OnClientAuthenticate(NetworkConnection conn)
public override void OnClientAuthenticate()
{
authenticator.OnClientAuthenticate(conn);
authenticator.OnClientAuthenticate();
if (timeout > 0)
StartCoroutine(BeginAuthentication(conn));
StartCoroutine(BeginAuthentication(NetworkClient.connection));
}

IEnumerator BeginAuthentication(NetworkConnection conn)
{
// Debug.Log($"Authentication countdown started {conn} {timeout}");

yield return new WaitForSecondsRealtime(timeout);

if (!conn.isAuthenticated)
{
// Debug.Log($"Authentication Timeout {conn}");

conn.Disconnect();
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 0 additions & 61 deletions UnityProject/Assets/Mirror/Cloud/ApiConnector.cs

This file was deleted.

8 changes: 0 additions & 8 deletions UnityProject/Assets/Mirror/Cloud/Core.meta

This file was deleted.

25 changes: 0 additions & 25 deletions UnityProject/Assets/Mirror/Cloud/Core/BaseApi.cs

This file was deleted.

12 changes: 0 additions & 12 deletions UnityProject/Assets/Mirror/Cloud/Core/Events.cs

This file was deleted.

12 changes: 0 additions & 12 deletions UnityProject/Assets/Mirror/Cloud/Core/Extensions.cs

This file was deleted.

12 changes: 0 additions & 12 deletions UnityProject/Assets/Mirror/Cloud/Core/ICoroutineRunner.cs

This file was deleted.

42 changes: 0 additions & 42 deletions UnityProject/Assets/Mirror/Cloud/Core/IRequestCreator.cs

This file was deleted.

26 changes: 0 additions & 26 deletions UnityProject/Assets/Mirror/Cloud/Core/IUnityEqualCheck.cs

This file was deleted.

24 changes: 0 additions & 24 deletions UnityProject/Assets/Mirror/Cloud/Core/JsonStructs.cs

This file was deleted.

Loading

0 comments on commit f988f2d

Please sign in to comment.