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

Commit 0067b50

Browse files
committed
Mirror override fix
1 parent a329f8f commit 0067b50

File tree

565 files changed

+1904
-3343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

565 files changed

+1904
-3343
lines changed

UnityProject/Assets/Mirror/Authenticators.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityProject/Assets/Mirror/Authenticators/BasicAuthenticator.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public class BasicAuthenticator : NetworkAuthenticator
1313
public string username;
1414
public string password;
1515

16+
// this is set if authentication fails to prevent garbage AuthRequestMessage spam
17+
bool ServerAuthFailed;
18+
1619
#region Messages
1720

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

103106
// disconnect the client after 1 second so that response message gets delivered
104-
StartCoroutine(DelayedDisconnect(conn, 1));
107+
if (!ServerAuthFailed)
108+
{
109+
// set this false so this coroutine can only be started once
110+
ServerAuthFailed = true;
111+
112+
StartCoroutine(DelayedDisconnect(conn, 1));
113+
}
105114
}
106115
}
107116

@@ -141,21 +150,23 @@ public override void OnStopClient()
141150
/// Called on client from OnClientAuthenticateInternal when a client needs to authenticate
142151
/// </summary>
143152
/// <param name="conn">Connection of the client.</param>
144-
public override void OnClientAuthenticate(NetworkConnection conn)
153+
public override void OnClientAuthenticate()
145154
{
146155
AuthRequestMessage authRequestMessage = new AuthRequestMessage
147156
{
148157
authUsername = username,
149158
authPassword = password
150159
};
151160

152-
conn.Send(authRequestMessage);
161+
NetworkClient.connection.Send(authRequestMessage);
153162
}
154163

164+
[Obsolete("Call OnAuthResponseMessage without the NetworkConnection parameter. It always points to NetworkClient.connection anyway.")]
165+
public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg) => OnAuthResponseMessage(msg);
166+
155167
/// <summary>
156168
/// Called on client when the server's AuthResponseMessage arrives
157169
/// </summary>
158-
/// <param name="conn">Connection to client.</param>
159170
/// <param name="msg">The message payload</param>
160171
public void OnAuthResponseMessage(AuthResponseMessage msg)
161172
{
@@ -164,20 +175,17 @@ public void OnAuthResponseMessage(AuthResponseMessage msg)
164175
// Debug.LogFormat(LogType.Log, "Authentication Response: {0}", msg.message);
165176

166177
// Authentication has been accepted
167-
ClientAccept(NetworkClient.connection);
178+
ClientAccept();
168179
}
169180
else
170181
{
171182
Debug.LogError($"Authentication Response: {msg.message}");
172183

173184
// Authentication has been rejected
174-
ClientReject(NetworkClient.connection);
185+
ClientReject();
175186
}
176187
}
177188

178-
[Obsolete("Call OnAuthResponseMessage without the NetworkConnection parameter. It always points to NetworkClient.connection anyway.")]
179-
public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg) => OnAuthResponseMessage(msg);
180-
181189
#endregion
182190
}
183191
}

UnityProject/Assets/Mirror/Authenticators/BasicAuthenticator.cs.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityProject/Assets/Mirror/Authenticators/Mirror.Authenticators.asmdef.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityProject/Assets/Mirror/Authenticators/TimeoutAuthenticator.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,21 @@ public override void OnServerAuthenticate(NetworkConnection conn)
4848
StartCoroutine(BeginAuthentication(conn));
4949
}
5050

51-
public override void OnClientAuthenticate(NetworkConnection conn)
51+
public override void OnClientAuthenticate()
5252
{
53-
authenticator.OnClientAuthenticate(conn);
53+
authenticator.OnClientAuthenticate();
5454
if (timeout > 0)
55-
StartCoroutine(BeginAuthentication(conn));
55+
StartCoroutine(BeginAuthentication(NetworkClient.connection));
5656
}
5757

5858
IEnumerator BeginAuthentication(NetworkConnection conn)
5959
{
6060
// Debug.Log($"Authentication countdown started {conn} {timeout}");
61-
6261
yield return new WaitForSecondsRealtime(timeout);
6362

6463
if (!conn.isAuthenticated)
6564
{
6665
// Debug.Log($"Authentication Timeout {conn}");
67-
6866
conn.Disconnect();
6967
}
7068
}

UnityProject/Assets/Mirror/Authenticators/TimeoutAuthenticator.cs.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityProject/Assets/Mirror/Cloud.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1 @@
1-
using Mirror.Cloud.ListServerService;
2-
using UnityEngine;
3-
4-
namespace Mirror.Cloud
5-
{
6-
/// <summary>
7-
/// Used to requests and responses from the mirror api
8-
/// </summary>
9-
public interface IApiConnector
10-
{
11-
ListServer ListServer { get; }
12-
}
13-
14-
/// <summary>
15-
/// Used to requests and responses from the mirror api
16-
/// </summary>
17-
[DisallowMultipleComponent]
18-
[AddComponentMenu("Network/CloudServices/ApiConnector")]
19-
[HelpURL("https://mirror-networking.com/docs/api/Mirror.Cloud.ApiConnector.html")]
20-
public class ApiConnector : MonoBehaviour, IApiConnector, ICoroutineRunner
21-
{
22-
#region Inspector
23-
[Header("Settings")]
24-
25-
[Tooltip("Base URL of api, including https")]
26-
[SerializeField] string ApiAddress = "";
27-
28-
[Tooltip("Api key required to access api")]
29-
[SerializeField] string ApiKey = "";
30-
31-
[Header("Events")]
32-
33-
[Tooltip("Triggered when server list updates")]
34-
[SerializeField] ServerListEvent _onServerListUpdated = new ServerListEvent();
35-
#endregion
36-
37-
IRequestCreator requestCreator;
38-
39-
public ListServer ListServer { get; private set; }
40-
41-
void Awake()
42-
{
43-
requestCreator = new RequestCreator(ApiAddress, ApiKey, this);
44-
45-
InitListServer();
46-
}
47-
48-
void InitListServer()
49-
{
50-
IListServerServerApi serverApi = new ListServerServerApi(this, requestCreator);
51-
IListServerClientApi clientApi = new ListServerClientApi(this, requestCreator, _onServerListUpdated);
52-
ListServer = new ListServer(serverApi, clientApi);
53-
}
54-
55-
public void OnDestroy()
56-
{
57-
ListServer?.ServerApi.Shutdown();
58-
ListServer?.ClientApi.Shutdown();
59-
}
60-
}
61-
}
1+
// removed 2021-05-13

UnityProject/Assets/Mirror/Cloud/ApiConnector.cs.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1 @@
1-
using System;
2-
3-
namespace Mirror.Cloud
4-
{
5-
public interface IBaseApi
6-
{
7-
/// <summary>
8-
/// Cleans up any data created by the instance
9-
/// <para>For Example: removing server from list</para>
10-
/// </summary>
11-
void Shutdown();
12-
}
13-
14-
public abstract class BaseApi
15-
{
16-
protected readonly ICoroutineRunner runner;
17-
protected readonly IRequestCreator requestCreator;
18-
19-
protected BaseApi(ICoroutineRunner runner, IRequestCreator requestCreator)
20-
{
21-
this.runner = runner ?? throw new ArgumentNullException(nameof(runner));
22-
this.requestCreator = requestCreator ?? throw new ArgumentNullException(nameof(requestCreator));
23-
}
24-
}
25-
}
1+
// removed 2021-05-13

0 commit comments

Comments
 (0)