breaking: Remove Obsoletes (#2909)

* breaking: Remove Obsoletes
- MIRROR_47_0_OR_NEWER symbol added
- A few obsoletes with Network Visibility remain...not ready to remove just yet.

* fixed test
This commit is contained in:
MrGadget 2021-09-06 12:10:36 -04:00 committed by GitHub
parent 3afd3ba726
commit 8612c023a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 13 additions and 615 deletions

View File

@ -151,10 +151,6 @@ public override void OnClientAuthenticate()
NetworkClient.connection.Send(authRequestMessage);
}
// Deprecated 2021-04-29
[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>

View File

@ -36,7 +36,8 @@ public static void AddDefineSymbols()
"MIRROR_42_0_OR_NEWER",
"MIRROR_43_0_OR_NEWER",
"MIRROR_44_0_OR_NEWER",
"MIRROR_46_0_OR_NEWER"
"MIRROR_46_0_OR_NEWER",
"MIRROR_47_0_OR_NEWER"
};
// only touch PlayerSettings if we actually modified it.

View File

@ -27,18 +27,6 @@ public class NetworkProximityChecker : NetworkVisibility
[Tooltip("How often (in seconds) that this object should update the list of observers that can see it.")]
public float visUpdateInterval = 1;
/// <summary>
/// Flag to force this object to be hidden for players.
/// <para>If this object is a player object, it will not be hidden for that player.</para>
/// </summary>
// Deprecated 2021-02-17
[Obsolete("Use NetworkIdentity.visible mode instead of forceHidden!")]
public bool forceHidden
{
get => netIdentity.visible == Visibility.ForceHidden;
set => netIdentity.visible = value ? Visibility.ForceHidden : Visibility.Default;
}
public override void OnStartServer()
{
InvokeRepeating(nameof(RebuildObservers), 0, visUpdateInterval);
@ -61,9 +49,6 @@ void RebuildObservers()
/// <returns>True if the player can see this object.</returns>
public override bool OnCheckObserver(NetworkConnection conn)
{
if (forceHidden)
return false;
return Vector3.Distance(conn.identity.transform.position, transform.position) < visRange;
}
@ -76,9 +61,6 @@ public override bool OnCheckObserver(NetworkConnection conn)
public override void OnRebuildObservers(HashSet<NetworkConnection> observers, bool initialize)
{
// if force hidden then return without adding any observers.
if (forceHidden)
return;
// 'transform.' calls GetComponent, only do it once
Vector3 position = transform.position;

View File

@ -1,95 +0,0 @@
// moved into NetworkClient on 2021-03-07
using System;
using System.Collections.Generic;
using UnityEngine;
using Guid = System.Guid;
namespace Mirror
{
// Deprecated 2021-03-07
[Obsolete("Use NetworkClient instead")]
public static class ClientScene
{
[Obsolete("ClientScene.localPlayer was moved to NetworkClient.localPlayer")]
public static NetworkIdentity localPlayer
{
get { return NetworkClient.localPlayer; }
set { NetworkClient.localPlayer = value; }
}
[Obsolete("ClientScene.ready was moved to NetworkClient.ready")]
public static bool ready
{
get { return NetworkClient.ready; }
set { NetworkClient.ready = value; }
}
[Obsolete("ClientScene.readyConnection was moved to NetworkClient.readyConnection")]
public static NetworkConnection readyConnection
{
get { return NetworkClient.readyConnection; }
set { NetworkClient.connection = value; }
}
[Obsolete("ClientScene.prefabs was moved to NetworkClient.prefabs")]
public static Dictionary<Guid, GameObject> prefabs => NetworkClient.prefabs;
// add player //////////////////////////////////////////////////////////
[Obsolete("ClientScene.AddPlayer was moved to NetworkClient.AddPlayer")]
public static bool AddPlayer(NetworkConnection readyConn) => NetworkClient.AddPlayer(readyConn);
// ready ///////////////////////////////////////////////////////////////
[Obsolete("ClientScene.Ready was moved to NetworkClient.Ready")]
public static bool Ready(NetworkConnection conn) => NetworkClient.Ready(conn);
[Obsolete("ClientScene.PrepareToSpawnSceneObjects was moved to NetworkClient.PrepareToSpawnSceneObjects")]
public static void PrepareToSpawnSceneObjects() => NetworkClient.PrepareToSpawnSceneObjects();
// spawnable prefabs ///////////////////////////////////////////////////
[Obsolete("ClientScene.GetPrefab was moved to NetworkClient.GetPrefab")]
public static bool GetPrefab(Guid assetId, out GameObject prefab) => NetworkClient.GetPrefab(assetId, out prefab);
[Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")]
public static void RegisterPrefab(GameObject prefab, Guid newAssetId) => NetworkClient.RegisterPrefab(prefab, newAssetId);
[Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")]
public static void RegisterPrefab(GameObject prefab) => NetworkClient.RegisterPrefab(prefab);
[Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")]
public static void RegisterPrefab(GameObject prefab, Guid newAssetId, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) =>
NetworkClient.RegisterPrefab(prefab, newAssetId, spawnHandler, unspawnHandler);
[Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")]
public static void RegisterPrefab(GameObject prefab, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) =>
NetworkClient.RegisterPrefab(prefab, spawnHandler, unspawnHandler);
[Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")]
public static void RegisterPrefab(GameObject prefab, Guid newAssetId, SpawnHandlerDelegate spawnHandler, UnSpawnDelegate unspawnHandler) =>
NetworkClient.RegisterPrefab(prefab, newAssetId, spawnHandler, unspawnHandler);
[Obsolete("ClientScene.RegisterPrefab was moved to NetworkClient.RegisterPrefab")]
public static void RegisterPrefab(GameObject prefab, SpawnHandlerDelegate spawnHandler, UnSpawnDelegate unspawnHandler) =>
NetworkClient.RegisterPrefab(prefab, spawnHandler, unspawnHandler);
[Obsolete("ClientScene.UnregisterPrefab was moved to NetworkClient.UnregisterPrefab")]
public static void UnregisterPrefab(GameObject prefab) => NetworkClient.UnregisterPrefab(prefab);
// spawn handlers //////////////////////////////////////////////////////
[Obsolete("ClientScene.RegisterSpawnHandler was moved to NetworkClient.RegisterSpawnHandler")]
public static void RegisterSpawnHandler(Guid assetId, SpawnDelegate spawnHandler, UnSpawnDelegate unspawnHandler) =>
NetworkClient.RegisterSpawnHandler(assetId, spawnHandler, unspawnHandler);
[Obsolete("ClientScene.RegisterSpawnHandler was moved to NetworkClient.RegisterSpawnHandler")]
public static void RegisterSpawnHandler(Guid assetId, SpawnHandlerDelegate spawnHandler, UnSpawnDelegate unspawnHandler) =>
NetworkClient.RegisterSpawnHandler(assetId, spawnHandler, unspawnHandler);
[Obsolete("ClientScene.UnregisterSpawnHandler was moved to NetworkClient.UnregisterSpawnHandler")]
public static void UnregisterSpawnHandler(Guid assetId) => NetworkClient.UnregisterSpawnHandler(assetId);
[Obsolete("ClientScene.ClearSpawners was moved to NetworkClient.ClearSpawners")]
public static void ClearSpawners() => NetworkClient.ClearSpawners();
[Obsolete("ClientScene.DestroyAllClientObjects was moved to NetworkClient.DestroyAllClientObjects")]
public static void DestroyAllClientObjects() => NetworkClient.DestroyAllClientObjects();
}
}

View File

@ -0,0 +1 @@
// moved into NetworkClient on 2021-03-07

View File

@ -3,14 +3,6 @@
namespace Mirror
{
// Deprecated 2020-10-06
[Obsolete("Implement NetworkMessage instead. Use extension methods instead of Serialize/Deserialize, see https://github.com/vis2k/Mirror/pull/2317", true)]
public interface IMessageBase {}
// Deprecated 2020-10-06
[Obsolete("Implement NetworkMessage instead. Use extension methods instead of Serialize/Deserialize, see https://github.com/vis2k/Mirror/pull/2317", true)]
public class MessageBase : IMessageBase {}
public struct ReadyMessage : NetworkMessage {}
public struct NotReadyMessage : NetworkMessage {}

View File

@ -44,26 +44,14 @@ public virtual void OnStartClient() {}
/// <summary>Called when client stops, used to unregister message handlers if needed.</summary>
public virtual void OnStopClient() {}
// Deprecated 2021-03-13
[Obsolete("Remove the NetworkConnection parameter from your override and use NetworkClient.connection instead")]
public virtual void OnClientAuthenticate(NetworkConnection conn) => OnClientAuthenticate();
/// <summary>Called on client from OnClientAuthenticateInternal when a client needs to authenticate</summary>
public abstract void OnClientAuthenticate();
// Deprecated 2021-03-13
[Obsolete("Remove the NetworkConnection parameter from your override and use NetworkClient.connection instead")]
protected void ClientAccept(NetworkConnection conn) => ClientAccept();
protected void ClientAccept()
{
OnClientAuthenticated.Invoke(NetworkClient.connection);
}
// Deprecated 2021-03-13
[Obsolete("Remove the NetworkConnection parameter from your override and use NetworkClient.connection instead")]
protected void ClientReject(NetworkConnection conn) => ClientReject();
protected void ClientReject()
{
// Set this on the client for local reference

View File

@ -39,12 +39,6 @@ public static class NetworkClient
// way better for security if we can check states in callbacks
public static bool ready;
/// <summary>The NetworkConnection object that is currently "ready".</summary>
// TODO this is from UNET. it's redundant and we should probably obsolete it.
// Deprecated 2021-03-10
[Obsolete("NetworkClient.readyConnection is redundant. Use NetworkClient.connection and use NetworkClient.ready to check if it's ready.")]
public static NetworkConnection readyConnection => ready ? connection : null;
/// <summary>NetworkIdentity of the localPlayer </summary>
public static NetworkIdentity localPlayer { get; internal set; }
@ -68,9 +62,6 @@ public static class NetworkClient
/// <summary>True if client is running in host mode.</summary>
public static bool isHostClient => connection is LocalConnectionToServer;
// Deprecated 2021-05-26
[Obsolete("isLocalClient was renamed to isHostClient because that's what it actually means.")]
public static bool isLocalClient => isHostClient;
// OnConnected / OnDisconnected used to be NetworkMessages that were
// invoked. this introduced a bug where external clients could send
@ -248,23 +239,6 @@ public static void Disconnect()
// connection = null;
}
/// <summary>Disconnect host mode.</summary>
// this is needed to call DisconnectMessage for the host client too.
// Deprecated 2021-05-11
[Obsolete("Call NetworkClient.Disconnect() instead. Nobody should use DisconnectLocalServer.")]
public static void DisconnectLocalServer()
{
// only if host connection is running
if (NetworkServer.localConnection != null)
{
// TODO ConnectLocalServer manually sends a ConnectMessage to the
// local connection. should we send a DisconnectMessage here too?
// (if we do then we get an Unknown Message ID log)
//NetworkServer.localConnection.Send(new DisconnectMessage());
NetworkServer.OnTransportDisconnected(NetworkServer.localConnection.connectionId);
}
}
// transport events ////////////////////////////////////////////////////
// called by Transport
static void OnTransportConnected()
@ -460,20 +434,6 @@ public static void Send<T>(T message, int channelId = Channels.Reliable)
}
// message handlers ////////////////////////////////////////////////////
/// <summary>Register a handler for a message type T. Most should require authentication.</summary>
// Deprecated 2021-03-13
[Obsolete("Use RegisterHandler<T> version without NetworkConnection parameter. It always points to NetworkClient.connection anyway.")]
public static void RegisterHandler<T>(Action<NetworkConnection, T> handler, bool requireAuthentication = true)
where T : struct, NetworkMessage
{
ushort msgType = MessagePacking.GetId<T>();
if (handlers.ContainsKey(msgType))
{
Debug.LogWarning($"NetworkClient.RegisterHandler replacing handler for {typeof(T).FullName}, id={msgType}. If replacement is intentional, use ReplaceHandler instead to avoid this warning.");
}
handlers[msgType] = MessagePacking.WrapHandler(handler, requireAuthentication);
}
/// <summary>Register a handler for a message type T. Most should require authentication.</summary>
public static void RegisterHandler<T>(Action<T> handler, bool requireAuthentication = true)
where T : struct, NetworkMessage
@ -961,10 +921,6 @@ public static bool Ready()
return true;
}
// Deprecated 2021-03-13
[Obsolete("NetworkClient.Ready doesn't need a NetworkConnection parameter anymore. It always uses NetworkClient.connection anyway.")]
public static bool Ready(NetworkConnection conn) => Ready();
// add player //////////////////////////////////////////////////////////
// called from message handler for Owner message
internal static void InternalAddPlayer(NetworkIdentity identity)
@ -1017,10 +973,6 @@ public static bool AddPlayer()
return true;
}
// Deprecated 2021-03-13
[Obsolete("NetworkClient.AddPlayer doesn't need a NetworkConnection parameter anymore. It always uses NetworkClient.connection anyway.")]
public static bool AddPlayer(NetworkConnection readyConn) => AddPlayer();
// spawning ////////////////////////////////////////////////////////////
internal static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage message)
{
@ -1398,11 +1350,6 @@ internal static void NetworkLateUpdate()
Transport.activeTransport.ClientLateUpdate();
}
// obsolete to not break people's projects. Update was public.
// Deprecated 2021-03-02
[Obsolete("NetworkClient.Update is now called internally from our custom update loop. No need to call Update manually anymore.")]
public static void Update() => NetworkLateUpdate();
// shutdown ////////////////////////////////////////////////////////////
/// <summary>Destroys all networked objects on the client.</summary>
// Note: NetworkServer.CleanupNetworkIdentities does the same on server.

View File

@ -23,7 +23,7 @@ public class NetworkManager : MonoBehaviour
[Tooltip("Should the Network Manager object be persisted through scene changes?")]
public bool dontDestroyOnLoad = true;
// Deprecated 2021-03-10
// Deprecated 2021-03-10
// Temporary bool to allow Network Manager to persist to offline scene
// Based on Discord convo, BigBox is invoking StopHost in startup sequence, bouncing the server and clients back to offline scene, which resets Network Manager.
// Request is for a checkbox to persist Network Manager to offline scene, despite the collision and warning.
@ -31,7 +31,7 @@ public class NetworkManager : MonoBehaviour
[Tooltip("Should the Network Manager object be persisted through scene change to the offline scene?")]
public bool PersistNetworkManagerToOfflineScene;
/// <summary>Multiplayer games should always run in the background so the network doesn't time out.</summary>
/// <summary>Multiplayer games should always run in the background so the network doesn't time out.</summary>
[FormerlySerializedAs("m_RunInBackground")]
[Tooltip("Multiplayer games should always run in the background so the network doesn't time out.")]
public bool runInBackground = true;
@ -74,14 +74,6 @@ public class NetworkManager : MonoBehaviour
[Tooltip("Maximum number of concurrent connections.")]
public int maxConnections = 100;
// Deprecated 2021-05-10
[Obsolete("Transport is responsible for timeouts.")]
public bool disconnectInactiveConnections;
// Deprecated 2021-05-10
[Obsolete("Transport is responsible for timeouts. Configure the Transport's timeout setting instead.")]
public float disconnectInactiveTimeout = 60f;
[Header("Authentication")]
[Tooltip("Authentication component attached to this object")]
public NetworkAuthenticator authenticator;
@ -257,12 +249,6 @@ void SetupServer()
ConfigureHeadlessFrameRate();
// Copy auto-disconnect settings to NetworkServer
#pragma warning disable 618
NetworkServer.disconnectInactiveTimeout = disconnectInactiveTimeout;
NetworkServer.disconnectInactiveConnections = disconnectInactiveConnections;
#pragma warning restore 618
// start listening to network connections
NetworkServer.Listen(maxConnections);
@ -646,7 +632,7 @@ public virtual void OnApplicationQuit()
}
}
// DEPRECATED 2021-07-21
// Deprecated 2021-07-21
[Obsolete("Renamed to ConfigureHeadlessFrameRate()")]
public virtual void ConfigureServerFrameRate() {}
@ -1246,10 +1232,6 @@ public virtual void OnServerAddPlayer(NetworkConnection conn)
NetworkServer.AddPlayerForConnection(conn, player);
}
// Deprecated 2021-02-13
[Obsolete("OnServerError was removed because it hasn't been used in a long time.")]
public virtual void OnServerError(NetworkConnection conn, int errorCode) {}
/// <summary>Called on server when transport raises an exception. NetworkConnection may be null.</summary>
public virtual void OnServerError(NetworkConnection conn, Exception exception) {}
@ -1286,10 +1268,6 @@ public virtual void OnClientDisconnect(NetworkConnection conn)
StopClient();
}
// Deprecated 2021-02-13
[Obsolete("OnClientError was removed because it hasn't been used in a long time.")]
public virtual void OnClientError(NetworkConnection conn, int errorCode) {}
/// <summary>Called on client when transport raises an exception.</summary>
public virtual void OnClientError(Exception exception) {}

View File

@ -14,10 +14,6 @@ public class NetworkManagerHUD : MonoBehaviour
{
NetworkManager manager;
// Deprecated 2021-02-24
[Obsolete("showGUI will be removed unless someone has a valid use case. Simply use or don't use the HUD component.")]
public bool showGUI = true;
public int offsetX;
public int offsetY;
@ -28,10 +24,6 @@ void Awake()
void OnGUI()
{
#pragma warning disable 618
if (!showGUI) return;
#pragma warning restore 618
GUILayout.BeginArea(new Rect(10 + offsetX, 40 + offsetY, 215, 9999));
if (!NetworkClient.isConnected && !NetworkServer.active)
{

View File

@ -129,20 +129,9 @@ public static class NetworkReaderExtensions
public static byte ReadByte(this NetworkReader reader) => reader.ReadByte();
public static sbyte ReadSByte(this NetworkReader reader) => (sbyte)reader.ReadByte();
public static char ReadChar(this NetworkReader reader) => (char)reader.ReadUShort();
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use ReadBool instead.")]
public static bool ReadBoolean(this NetworkReader reader) => reader.ReadBool();
public static bool ReadBool(this NetworkReader reader) => reader.ReadByte() != 0;
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use ReadShort instead.")]
public static short ReadInt16(this NetworkReader reader) => reader.ReadShort();
public static short ReadShort(this NetworkReader reader) => (short)reader.ReadUShort();
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use ReadUShort instead.")]
public static ushort ReadUInt16(this NetworkReader reader) => reader.ReadUShort();
public static ushort ReadUShort(this NetworkReader reader)
{
ushort value = 0;
@ -151,14 +140,8 @@ public static ushort ReadUShort(this NetworkReader reader)
return value;
}
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use ReadInt instead.")]
public static int ReadInt32(this NetworkReader reader) => reader.ReadInt();
public static int ReadInt(this NetworkReader reader) => (int)reader.ReadUInt();
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use ReadUInt instead.")]
public static uint ReadUInt32(this NetworkReader reader) => reader.ReadUInt();
public static uint ReadUInt(this NetworkReader reader)
{
uint value = 0;
@ -169,14 +152,8 @@ public static uint ReadUInt(this NetworkReader reader)
return value;
}
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use ReadLong instead.")]
public static long ReadInt64(this NetworkReader reader) => reader.ReadLong();
public static long ReadLong(this NetworkReader reader) => (long)reader.ReadULong();
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use ReadULong instead.")]
public static ulong ReadUInt64(this NetworkReader reader) => reader.ReadULong();
public static ulong ReadULong(this NetworkReader reader)
{
ulong value = 0;
@ -191,9 +168,6 @@ public static ulong ReadULong(this NetworkReader reader)
return value;
}
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use ReadFloat instead.")]
public static float ReadSingle(this NetworkReader reader) => reader.ReadFloat();
public static float ReadFloat(this NetworkReader reader)
{
UIntFloat converter = new UIntFloat();

View File

@ -45,14 +45,6 @@ public static class NetworkServer
// by default, everyone observes everyone
public static InterestManagement aoi;
// Deprecated 2021-05-10
[Obsolete("Transport is responsible for timeouts.")]
public static bool disconnectInactiveConnections;
// Deprecated 2021-05-10
[Obsolete("Transport is responsible for timeouts. Configure the Transport's timeout setting instead.")]
public static float disconnectInactiveTimeout = 60f;
// OnConnected / OnDisconnected used to be NetworkMessages that were
// invoked. this introduced a bug where external clients could send
// Connected/Disconnected messages over the network causing undefined
@ -242,10 +234,6 @@ public static bool NoExternalConnections()
(connections.Count == 1 && localConnection != null);
}
// Deprecated 2021-03-07
[Obsolete("NoConnections was renamed to NoExternalConnections because that's what it checks for.")]
public static bool NoConnections() => NoExternalConnections();
// send ////////////////////////////////////////////////////////////////
/// <summary>Send a message to all clients, even those that haven't joined the world yet (non ready)</summary>
public static void SendToAll<T>(T message, int channelId = Channels.Reliable, bool sendToReadyOnly = false)
@ -357,22 +345,6 @@ static void SendToObservers<T>(NetworkIdentity identity, T message, int channelI
}
}
/// <summary>Send this message to the player only</summary>
// Deprecated 2021-03-04
[Obsolete("Use identity.connectionToClient.Send() instead! Previously Mirror needed this function internally, but not anymore.")]
public static void SendToClientOfPlayer<T>(NetworkIdentity identity, T msg, int channelId = Channels.Reliable)
where T : struct, NetworkMessage
{
if (identity != null)
{
identity.connectionToClient.Send(msg, channelId);
}
else
{
Debug.LogError("SendToClientOfPlayer: player has no NetworkIdentity: " + identity);
}
}
// transport events ////////////////////////////////////////////////////
// called by transport
static void OnTransportConnected(int connectionId)
@ -593,15 +565,6 @@ public static void RegisterHandler<T>(Action<NetworkConnection, T> handler, bool
handlers[msgType] = MessagePacking.WrapHandler(handler, requireAuthentication);
}
/// <summary>Register a handler for message type T. Most should require authentication.</summary>
// Deprecated 2021-02-24
[Obsolete("Use RegisterHandler(Action<NetworkConnection, T), requireAuthentication instead.")]
public static void RegisterHandler<T>(Action<T> handler, bool requireAuthentication = true)
where T : struct, NetworkMessage
{
RegisterHandler<T>((_, value) => { handler(value); }, requireAuthentication);
}
/// <summary>Replace a handler for message type T. Most should require authentication.</summary>
public static void ReplaceHandler<T>(Action<NetworkConnection, T> handler, bool requireAuthentication = true)
where T : struct, NetworkMessage
@ -678,14 +641,6 @@ public static void DisconnectAll()
active = false;
}
// Deprecated 2021-05-11
[Obsolete("Call NetworkClient.DisconnectAll() instead")]
public static void DisconnectAllExternalConnections() => DisconnectAll();
// Deprecated 2021-05-11
[Obsolete("Call NetworkClient.DisconnectAll() instead")]
public static void DisconnectAllConnections() => DisconnectAll();
// add/remove/replace player ///////////////////////////////////////////
/// <summary>Called by server after AddPlayer message to add the player for the connection.</summary>
// When a player is added for a connection, the client for that
@ -1620,24 +1575,6 @@ static void BroadcastToConnection(NetworkConnectionToClient connection)
}
}
// helper function to check a connection for inactivity
// and disconnect if necessary
// => returns true if disconnected
static bool DisconnectIfInactive(NetworkConnectionToClient connection)
{
// check for inactivity
#pragma warning disable 618
if (disconnectInactiveConnections &&
!connection.IsAlive(disconnectInactiveTimeout))
{
Debug.LogWarning($"Disconnecting {connection} for inactivity!");
connection.Disconnect();
return true;
}
#pragma warning restore 618
return false;
}
// NetworkLateUpdate called after any Update/FixedUpdate/LateUpdate
// (we add this to the UnityEngine in NetworkLoop)
static readonly List<NetworkConnectionToClient> connectionsCopy =
@ -1659,10 +1596,6 @@ static void Broadcast()
// go through all connections
foreach (NetworkConnectionToClient connection in connectionsCopy)
{
// check for inactivity. disconnects if necessary.
if (DisconnectIfInactive(connection))
continue;
// has this connection joined the world yet?
// for each READY connection:
// pull in UpdateVarsMessage for each entity it observes
@ -1710,10 +1643,5 @@ internal static void NetworkLateUpdate()
if (Transport.activeTransport != null)
Transport.activeTransport.ServerLateUpdate();
}
// obsolete to not break people's projects. Update was public.
// Deprecated 2021-03-02
[Obsolete("NetworkServer.Update is now called internally from our custom update loop. No need to call Update manually anymore.")]
public static void Update() => NetworkLateUpdate();
}
}

View File

@ -55,18 +55,10 @@ static NetworkTime()
// TODO does this need to be public? user should only need NetworkTime.time
public static double timeVariance => _offset.Var;
// Deprecated 2021-03-10
[Obsolete("NetworkTime.timeVar was renamed to timeVariance")]
public static double timeVar => timeVariance;
/// <summary>Time standard deviation. The highe, the less accurate the time is.</summary>
// TODO does this need to be public? user should only need NetworkTime.time
public static double timeStandardDeviation => Math.Sqrt(timeVariance);
// Deprecated 2021-03-10
[Obsolete("NetworkTime.timeSd was renamed to timeStandardDeviation")]
public static double timeSd => timeStandardDeviation;
/// <summary>Clock difference in seconds between the client and the server. Always 0 on server.</summary>
public static double offset => _offset.Value;
@ -77,18 +69,10 @@ static NetworkTime()
// TODO does this need to be public? user should only need NetworkTime.time
public static double rttVariance => _rtt.Var;
// Deprecated 2021-03-02
[Obsolete("NetworkTime.rttVar was renamed to rttVariance")]
public static double rttVar => rttVariance;
/// <summary>Round trip time standard deviation. The higher, the less accurate the rtt is.</summary>
// TODO does this need to be public? user should only need NetworkTime.time
public static double rttStandardDeviation => Math.Sqrt(rttVariance);
// Deprecated 2021-03-02
[Obsolete("NetworkTime.rttSd was renamed to rttStandardDeviation")]
public static double rttSd => rttStandardDeviation;
public static void Reset()
{
stopwatch.Restart();

View File

@ -105,28 +105,16 @@ public static class NetworkWriterExtensions
public static void WriteChar(this NetworkWriter writer, char value) => writer.WriteUShort(value);
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use WriteBool instead.")]
public static void WriteBoolean(this NetworkWriter writer, bool value) => writer.WriteBool(value);
public static void WriteBool(this NetworkWriter writer, bool value) => writer.WriteByte((byte)(value ? 1 : 0));
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use WriteUShort instead.")]
public static void WriteUInt16(this NetworkWriter writer, ushort value) => writer.WriteUShort(value);
public static void WriteUShort(this NetworkWriter writer, ushort value)
{
writer.WriteByte((byte)value);
writer.WriteByte((byte)(value >> 8));
}
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use WriteShort instead.")]
public static void WriteInt16(this NetworkWriter writer, short value) => writer.WriteShort(value);
public static void WriteShort(this NetworkWriter writer, short value) => writer.WriteUShort((ushort)value);
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use WriteUInt instead.")]
public static void WriteUInt32(this NetworkWriter writer, uint value) => writer.WriteUInt(value);
public static void WriteUInt(this NetworkWriter writer, uint value)
{
writer.WriteByte((byte)value);
@ -135,14 +123,8 @@ public static void WriteUInt(this NetworkWriter writer, uint value)
writer.WriteByte((byte)(value >> 24));
}
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use WriteInt instead.")]
public static void WriteInt32(this NetworkWriter writer, int value) => writer.WriteInt(value);
public static void WriteInt(this NetworkWriter writer, int value) => writer.WriteUInt((uint)value);
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use WriteULong instead.")]
public static void WriteUInt64(this NetworkWriter writer, ulong value) => writer.WriteULong(value);
public static void WriteULong(this NetworkWriter writer, ulong value)
{
writer.WriteByte((byte)value);
@ -155,14 +137,8 @@ public static void WriteULong(this NetworkWriter writer, ulong value)
writer.WriteByte((byte)(value >> 56));
}
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use WriteLong instead.")]
public static void WriteInt64(this NetworkWriter writer, long value) => writer.WriteLong(value);
public static void WriteLong(this NetworkWriter writer, long value) => writer.WriteULong((ulong)value);
// Deprecated 2021-05-18
[Obsolete("We've cleaned up the API. Use WriteFloat instead.")]
public static void WriteSingle(this NetworkWriter writer, float value) => writer.WriteFloat(value);
public static void WriteFloat(this NetworkWriter writer, float value)
{
UIntFloat converter = new UIntFloat

View File

@ -4,26 +4,6 @@
namespace Mirror
{
// Deprecated 2020-10-02
[Obsolete("Use SyncList<string> instead")]
public class SyncListString : SyncList<string> {}
// Deprecated 2020-10-02
[Obsolete("Use SyncList<float> instead")]
public class SyncListFloat : SyncList<float> {}
// Deprecated 2020-10-02
[Obsolete("Use SyncList<int> instead")]
public class SyncListInt : SyncList<int> {}
// Deprecated 2020-10-02
[Obsolete("Use SyncList<uint> instead")]
public class SyncListUInt : SyncList<uint> {}
// Deprecated 2020-10-02
[Obsolete("Use SyncList<bool> instead")]
public class SyncListBool : SyncList<bool> {}
public class SyncList<T> : IList<T>, IReadOnlyList<T>, SyncObject
{
public delegate void SyncListChanged(Operation op, int itemIndex, T oldItem, T newItem);

View File

@ -1,178 +1 @@
// uses the first available transport for server and client.
// example: to use Apathy if on Windows/Mac/Linux and fall back to Telepathy
// otherwise.
using System;
using UnityEngine;
namespace Mirror
{
// Deprecated 2021-05-13
[HelpURL("https://mirror-networking.gitbook.io/docs/transports/fallback-transport")]
[DisallowMultipleComponent]
[Obsolete("Fallback Transport will be retired. It was only needed for Apathy/Libuv. Use kcp or Telepathy instead, those run everywhere.")]
public class FallbackTransport : Transport
{
public Transport[] transports;
// the first transport that is available on this platform
Transport available;
public void Awake()
{
if (transports == null || transports.Length == 0)
{
throw new Exception("FallbackTransport requires at least 1 underlying transport");
}
available = GetAvailableTransport();
Debug.Log("FallbackTransport available: " + available.GetType());
}
void OnEnable()
{
available.enabled = true;
}
void OnDisable()
{
available.enabled = false;
}
// The client just uses the first transport available
Transport GetAvailableTransport()
{
foreach (Transport transport in transports)
{
if (transport.Available())
{
return transport;
}
}
throw new Exception("No transport suitable for this platform");
}
public override bool Available()
{
return available.Available();
}
public override void ClientConnect(string address)
{
available.OnClientConnected = OnClientConnected;
available.OnClientDataReceived = OnClientDataReceived;
available.OnClientError = OnClientError;
available.OnClientDisconnected = OnClientDisconnected;
available.ClientConnect(address);
}
public override void ClientConnect(Uri uri)
{
foreach (Transport transport in transports)
{
if (transport.Available())
{
try
{
transport.ClientConnect(uri);
available = transport;
}
catch (ArgumentException)
{
// transport does not support the schema, just move on to the next one
}
}
}
throw new Exception("No transport suitable for this platform");
}
public override bool ClientConnected()
{
return available.ClientConnected();
}
public override void ClientDisconnect()
{
available.ClientDisconnect();
}
public override void ClientSend(ArraySegment<byte> segment, int channelId)
{
available.ClientSend(segment, channelId);
}
// right now this just returns the first available uri,
// should we return the list of all available uri?
public override Uri ServerUri() => available.ServerUri();
public override bool ServerActive()
{
return available.ServerActive();
}
public override string ServerGetClientAddress(int connectionId)
{
return available.ServerGetClientAddress(connectionId);
}
public override void ServerDisconnect(int connectionId)
{
available.ServerDisconnect(connectionId);
}
public override void ServerSend(int connectionId, ArraySegment<byte> segment, int channelId)
{
available.ServerSend(connectionId, segment, channelId);
}
public override void ServerStart()
{
available.OnServerConnected = OnServerConnected;
available.OnServerDataReceived = OnServerDataReceived;
available.OnServerError = OnServerError;
available.OnServerDisconnected = OnServerDisconnected;
available.ServerStart();
}
public override void ServerStop()
{
available.ServerStop();
}
public override void ClientEarlyUpdate() => available.ClientEarlyUpdate();
public override void ServerEarlyUpdate() => available.ServerEarlyUpdate();
public override void ClientLateUpdate() => available.ClientLateUpdate();
public override void ServerLateUpdate() => available.ServerLateUpdate();
public override void Shutdown()
{
available.Shutdown();
}
public override int GetMaxPacketSize(int channelId = 0)
{
// finding the max packet size in a fallback environment has to be
// done very carefully:
// * servers and clients might run different transports depending on
// which platform they are on.
// * there should only ever be ONE true max packet size for everyone,
// otherwise a spawn message might be sent to all tcp sockets, but
// be too big for some udp sockets. that would be a debugging
// nightmare and allow for possible exploits and players on
// different platforms seeing a different game state.
// => the safest solution is to use the smallest max size for all
// transports. that will never fail.
int mininumAllowedSize = int.MaxValue;
foreach (Transport transport in transports)
{
int size = transport.GetMaxPacketSize(channelId);
mininumAllowedSize = Mathf.Min(size, mininumAllowedSize);
}
return mininumAllowedSize;
}
public override string ToString()
{
return available.ToString();
}
}
}
// removed 2021-05-13

View File

@ -64,17 +64,8 @@ public virtual void ClientConnect(Uri uri)
/// <summary>Sends a message to the server over the given channel.</summary>
// The ArraySegment is only valid until returning. Copy if needed.
// TODO make second version abstract after removing the obsolete version
// Deprecated 2021-05-17
[Obsolete("Use ClientSend(segment, channelId) instead. channelId is now the last parameter.")]
public virtual void ClientSend(int channelId, ArraySegment<byte> segment) {}
public virtual void ClientSend(ArraySegment<byte> segment, int channelId)
{
// defaults to obsolete version to not force break transports.
#pragma warning disable 618
ClientSend(channelId, segment);
#pragma warning restore 618
}
// TODO make abstract
public virtual void ClientSend(ArraySegment<byte> segment, int channelId) {}
/// <summary>Disconnects the client from the server</summary>
public abstract void ClientDisconnect();
@ -103,17 +94,8 @@ public virtual void ClientSend(ArraySegment<byte> segment, int channelId)
public abstract void ServerStart();
/// <summary>Send a message to a client over the given channel.</summary>
// TODO make second version abstract after removing the obsolete version
// Deprecated 2021-05-17
[Obsolete("Use ServerSend(connectionId, segment, channelId) instead. channelId is now the last parameter.")]
public virtual void ServerSend(int connectionId, int channelId, ArraySegment<byte> segment) {}
public virtual void ServerSend(int connectionId, ArraySegment<byte> segment, int channelId)
{
// defaults to obsolete version to not force break transports.
#pragma warning disable 618
ServerSend(connectionId, channelId, segment);
#pragma warning restore 618
}
// TODO make abstract
public virtual void ServerSend(int connectionId, ArraySegment<byte> segment, int channelId) {}
/// <summary>Disconnect a client from the server.</summary>
public abstract void ServerDisconnect(int connectionId);
@ -140,17 +122,9 @@ public virtual void ServerSend(int connectionId, ArraySegment<byte> segment, int
// slow (head of line blocking etc.).
public virtual int GetBatchThreshold(int channelId)
{
// change to GetMaxPacketSize by default after removing obsolete
#pragma warning disable 618
return GetMaxBatchSize(channelId);
#pragma warning restore 618
return GetMaxPacketSize(channelId);
}
// Deprecated 2021-06-17
[Obsolete("GetMaxBatchSize was renamed to GetBatchThreshold.")]
public virtual int GetMaxBatchSize(int channelId) =>
GetMaxPacketSize(channelId);
// block Update & LateUpdate to show warnings if Transports still use
// them instead of using
// Client/ServerEarlyUpdate: to process incoming messages

View File

@ -23,13 +23,6 @@ public enum MirrorInvokeType
ClientRpc
}
// Deprecated 2021-03-15
[Obsolete("Version has never been used, neither by UNET nor by Mirror.")]
public enum Version
{
Current = 1
}
// channels are const ints instead of an enum so people can add their own
// channels (can't extend an enum otherwise).
//
@ -41,14 +34,6 @@ public static class Channels
{
public const int Reliable = 0; // ordered
public const int Unreliable = 1; // unordered
// Deprecated 2021-03-15
[Obsolete("Use Channels.Reliable instead")]
public const int DefaultReliable = Reliable;
// Deprecated 2021-03-15
[Obsolete("Use Channels.Unreliable instead")]
public const int DefaultUnreliable = Unreliable;
}
// -- helpers for float conversion without allocations --

View File

@ -1259,10 +1259,6 @@ public void UpdateDetectsDestroyedEntryInObserving()
public void UpdateWithTimedOutConnection()
{
// configure to disconnect with '0' timeout (= immediately)
#pragma warning disable 618
NetworkServer.disconnectInactiveConnections = true;
NetworkServer.disconnectInactiveTimeout = 0;
// start
NetworkServer.Listen(1);
@ -1271,10 +1267,6 @@ public void UpdateWithTimedOutConnection()
// update
NetworkServer.NetworkLateUpdate();
// clean up
NetworkServer.disconnectInactiveConnections = false;
#pragma warning restore 618
}
}
}

View File

@ -576,7 +576,7 @@ PlayerSettings:
webGLThreadsSupport: 0
webGLWasmStreaming: 0
scriptingDefineSymbols:
1: MIRROR;MIRROR_17_0_OR_NEWER;MIRROR_18_0_OR_NEWER;MIRROR_24_0_OR_NEWER;MIRROR_26_0_OR_NEWER;MIRROR_27_0_OR_NEWER;MIRROR_28_0_OR_NEWER;MIRROR_29_0_OR_NEWER;MIRROR_30_0_OR_NEWER;MIRROR_30_5_2_OR_NEWER;MIRROR_32_1_2_OR_NEWER;MIRROR_32_1_4_OR_NEWER;MIRROR_35_0_OR_NEWER;MIRROR_35_1_OR_NEWER;MIRROR_37_0_OR_NEWER;MIRROR_38_0_OR_NEWER;MIRROR_39_0_OR_NEWER;MIRROR_40_0_OR_NEWER;MIRROR_41_0_OR_NEWER;MIRROR_42_0_OR_NEWER;MIRROR_43_0_OR_NEWER;MIRROR_44_0_OR_NEWER;MIRROR_46_0_OR_NEWER
1: MIRROR;MIRROR_17_0_OR_NEWER;MIRROR_18_0_OR_NEWER;MIRROR_24_0_OR_NEWER;MIRROR_26_0_OR_NEWER;MIRROR_27_0_OR_NEWER;MIRROR_28_0_OR_NEWER;MIRROR_29_0_OR_NEWER;MIRROR_30_0_OR_NEWER;MIRROR_30_5_2_OR_NEWER;MIRROR_32_1_2_OR_NEWER;MIRROR_32_1_4_OR_NEWER;MIRROR_35_0_OR_NEWER;MIRROR_35_1_OR_NEWER;MIRROR_37_0_OR_NEWER;MIRROR_38_0_OR_NEWER;MIRROR_39_0_OR_NEWER;MIRROR_40_0_OR_NEWER;MIRROR_41_0_OR_NEWER;MIRROR_42_0_OR_NEWER;MIRROR_43_0_OR_NEWER;MIRROR_44_0_OR_NEWER;MIRROR_46_0_OR_NEWER;MIRROR_47_0_OR_NEWER
platformArchitecture: {}
scriptingBackend: {}
il2cppCompilerConfiguration: {}