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)
{
connectedEventPending = false;
NetworkClient.OnConnectedEvent?.Invoke(this);
NetworkClient.OnConnectedEvent?.Invoke();
}
// process internal messages so they are applied at the correct time
@ -99,7 +99,7 @@ internal void Update()
if (disconnectedEventPending)
{
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
// Connected/Disconnected messages over the network causing undefined
// behaviour.
internal static Action<NetworkConnection> OnConnectedEvent;
internal static Action<NetworkConnection> OnDisconnectedEvent;
internal static Action OnConnectedEvent;
internal static Action OnDisconnectedEvent;
/// <summary>Registered spawnable prefabs by assetId.</summary>
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
connectState = ConnectState.Connected;
NetworkTime.UpdateClient();
OnConnectedEvent?.Invoke(connection);
OnConnectedEvent?.Invoke();
}
else Debug.LogError("Skipped Connect message handling because connection is null.");
}
@ -281,7 +281,7 @@ static void OnDisconnected()
connectState = ConnectState.Disconnected;
ready = false;
if (connection != null) OnDisconnectedEvent?.Invoke(connection);
if (connection != null) OnDisconnectedEvent?.Invoke();
}
static void OnError(Exception exception) => Debug.LogException(exception);

View File

@ -1113,19 +1113,19 @@ void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage msg)
OnServerAddPlayer(conn);
}
void OnClientConnectInternal(NetworkConnection conn)
void OnClientConnectInternal()
{
//Debug.Log("NetworkManager.OnClientConnectInternal");
if (authenticator != null)
{
// we have an authenticator - let it handle authentication
authenticator.OnClientAuthenticate(conn);
authenticator.OnClientAuthenticate(NetworkClient.connection);
}
else
{
// 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");
OnClientDisconnect(conn);
OnClientDisconnect(NetworkClient.connection);
}
void OnClientNotReadyMessageInternal(NetworkConnection conn, NotReadyMessage msg)