NetworkClient.OnConnected/DisconnectEvent: remove redundant NetworkConnection parameter. It's always NetworkClient.connection anyway.

This commit is contained in:
vis2k 2021-03-13 19:22:57 +08:00
parent f38d29b61c
commit 5bf7be143c
3 changed files with 11 additions and 11 deletions

View File

@ -81,7 +81,7 @@ internal void Update()
if (connectedEventPending) if (connectedEventPending)
{ {
connectedEventPending = false; connectedEventPending = false;
NetworkClient.OnConnectedEvent?.Invoke(this); NetworkClient.OnConnectedEvent?.Invoke();
} }
// process internal messages so they are applied at the correct time // process internal messages so they are applied at the correct time
@ -99,7 +99,7 @@ internal void Update()
if (disconnectedEventPending) if (disconnectedEventPending)
{ {
disconnectedEventPending = false; disconnectedEventPending = false;
NetworkClient.OnDisconnectedEvent?.Invoke(this); NetworkClient.OnDisconnectedEvent?.Invoke();
} }
} }

View File

@ -64,8 +64,8 @@ public static class NetworkClient
// invoked. this introduced a bug where external clients could send // invoked. this introduced a bug where external clients could send
// Connected/Disconnected messages over the network causing undefined // Connected/Disconnected messages over the network causing undefined
// behaviour. // behaviour.
internal static Action<NetworkConnection> OnConnectedEvent; internal static Action OnConnectedEvent;
internal static Action<NetworkConnection> OnDisconnectedEvent; internal static Action OnDisconnectedEvent;
/// <summary>Registered spawnable prefabs by assetId.</summary> /// <summary>Registered spawnable prefabs by assetId.</summary>
public static readonly Dictionary<Guid, GameObject> prefabs = public static readonly Dictionary<Guid, GameObject> prefabs =
@ -262,7 +262,7 @@ static void OnConnected()
// thus we should set the connected state before calling the handler // thus we should set the connected state before calling the handler
connectState = ConnectState.Connected; connectState = ConnectState.Connected;
NetworkTime.UpdateClient(); NetworkTime.UpdateClient();
OnConnectedEvent?.Invoke(connection); OnConnectedEvent?.Invoke();
} }
else Debug.LogError("Skipped Connect message handling because connection is null."); else Debug.LogError("Skipped Connect message handling because connection is null.");
} }
@ -281,7 +281,7 @@ static void OnDisconnected()
connectState = ConnectState.Disconnected; connectState = ConnectState.Disconnected;
ready = false; ready = false;
if (connection != null) OnDisconnectedEvent?.Invoke(connection); if (connection != null) OnDisconnectedEvent?.Invoke();
} }
static void OnError(Exception exception) => Debug.LogException(exception); static void OnError(Exception exception) => Debug.LogException(exception);

View File

@ -1113,19 +1113,19 @@ void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage msg)
OnServerAddPlayer(conn); OnServerAddPlayer(conn);
} }
void OnClientConnectInternal(NetworkConnection conn) void OnClientConnectInternal()
{ {
//Debug.Log("NetworkManager.OnClientConnectInternal"); //Debug.Log("NetworkManager.OnClientConnectInternal");
if (authenticator != null) if (authenticator != null)
{ {
// we have an authenticator - let it handle authentication // we have an authenticator - let it handle authentication
authenticator.OnClientAuthenticate(conn); authenticator.OnClientAuthenticate(NetworkClient.connection);
} }
else else
{ {
// authenticate immediately // authenticate immediately
OnClientAuthenticated(conn); OnClientAuthenticated(NetworkClient.connection);
} }
} }
@ -1151,10 +1151,10 @@ void OnClientAuthenticated(NetworkConnection conn)
} }
} }
void OnClientDisconnectInternal(NetworkConnection conn) void OnClientDisconnectInternal()
{ {
//Debug.Log("NetworkManager.OnClientDisconnectInternal"); //Debug.Log("NetworkManager.OnClientDisconnectInternal");
OnClientDisconnect(conn); OnClientDisconnect(NetworkClient.connection);
} }
void OnClientNotReadyMessageInternal(NetworkConnection conn, NotReadyMessage msg) void OnClientNotReadyMessageInternal(NetworkConnection conn, NotReadyMessage msg)