removed obsoletes (#1542)

* lobby

* networkroommanager

* networkanimatoreditor

* networkidentityeditor

* preprocessordefine

* clientscene

* customattributes

* localclient

* messages

* networkbehaviour

* networkclient

* networkconnection

* networkidentity

* networkmanager

* networkserver

* networkwriter

* syncdictionary

* synclist

* unetwork

* transport

* networkmessage

* remove leftover obsoletes

* NetworkServer

* NetworkManager

* NetworkRoomManager

* NetworkRoomManager

* AddPlayerMessage

* NetworkLobbyManager & NetworkLobbyPlayer

* PreprocessorDefine

* Removed usings

* Commented test class

* Restored NetworkMessage as empty file

* Removed SyncVarSTRUCT tests

* Removed SyncVarSTRUCT tests

Co-authored-by: Chris Langsenkamp <chris@clevertech.net>

leaving a few ones still in there:

addplayermessage
llapi because still useful
networkbehaviour.getrpchandler for networkprofiler

BREAKING CHANGE: removed obsoletes
This commit is contained in:
vis2k 2020-03-17 21:25:36 +01:00 committed by GitHub
parent 7bd137847d
commit 4faec29559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 43 additions and 1282 deletions

View File

@ -23,7 +23,8 @@ public static void AddDefineSymbols()
"MIRROR_7_0_OR_NEWER",
"MIRROR_8_0_OR_NEWER",
"MIRROR_9_0_OR_NEWER",
"MIRROR_10_0_OR_NEWER"
"MIRROR_10_0_OR_NEWER",
"MIRROR_11_0_OR_NEWER"
};
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, string.Join(";", defines));
}

View File

@ -1,5 +0,0 @@
// This file was removed in Mirror 3.4.9
// The purpose of this file is to get the old file overwritten
// when users update from the asset store to prevent a flood of errors
// from having the old file still in the project as a straggler.
// This file will be dropped from the Asset Store package in May 2019

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 9589e903d4e98490fb1157762a307fd7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1 +0,0 @@
// This file has been removed

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ae4acb8316d250d4f9e9604c3b0051a4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +0,0 @@
// This file was moved to Mirror/CompilerSymbols in Mirror 4.0
// The purpose of this file is to get the old file overwritten
// when users update from the asset store to prevent a flood of errors
// from having the old file still in the project as a straggler.

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 42760e6965bea614ca5706a6ba059531
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using UnityEngine;
using Guid = System.Guid;
@ -132,13 +130,7 @@ public static bool AddPlayer(NetworkConnection readyConn, byte[] extraData)
if (LogFilter.Debug) Debug.Log("ClientScene.AddPlayer() called with connection [" + readyConnection + "]");
AddPlayerMessage message = new AddPlayerMessage
{
#pragma warning disable CS0618 // Type or member is obsolete
value = extraData
#pragma warning restore CS0618 // Type or member is obsolete
};
readyConnection.Send(message);
readyConnection.Send(new AddPlayerMessage());
return true;
}
@ -459,20 +451,6 @@ public static void DestroyAllClientObjects()
NetworkIdentity.spawned.Clear();
}
// Deprecated 01/15/2019
/// <summary>
/// Obsolete: Use <see cref="NetworkIdentity.spawned"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkIdentity.spawned[netId] instead.")]
public static GameObject FindLocalObject(uint netId)
{
if (NetworkIdentity.spawned.TryGetValue(netId, out NetworkIdentity identity))
{
return identity.gameObject;
}
return null;
}
static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage msg)
{
identity.Reset();

View File

@ -1,17 +1,8 @@
using System;
using System.ComponentModel;
using UnityEngine;
namespace Mirror
{
// Deprecated 12/31/2018
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkBehaviour.syncInterval field instead. Can be modified in the Inspector too.")]
[AttributeUsage(AttributeTargets.Class)]
public class NetworkSettingsAttribute : Attribute
{
public float sendInterval = 0.1f;
}
/// <summary>
/// SyncVars are used to synchronize a variable from the server to all clients automatically.
/// <para>Value must be changed on server, not directly by clients. Hook parameter allows you to define a client-side method to be invoked when the client gets an update from the server.</para>

View File

@ -1,5 +0,0 @@
// This file was removed in Mirror 3.4.9
// The purpose of this file is to get the old file overwritten
// when users update from the asset store to prevent a flood of errors
// from having the old file still in the project as a straggler.
// This file will be dropped from the Asset Store package in May 2019

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5c4d04450e91c438385de7300abef1b6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -30,30 +30,6 @@ public static int GetId(Type type)
return type.FullName.GetStableHashCode() & 0xFFFF;
}
// pack message before sending
// -> NetworkWriter passed as arg so that we can use .ToArraySegment
// and do an allocation free send before recycling it.
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Pack<T> instead")]
public static byte[] PackMessage(int msgType, MessageBase msg)
{
using (PooledNetworkWriter writer = NetworkWriterPool.GetWriter())
{
try
{
// write message type
writer.WriteInt16((short)msgType);
// serialize message into writer
msg.Serialize(writer);
// return byte[]
return writer.ToArray();
}
finally { }
}
}
// pack message before sending
// -> NetworkWriter passed as arg so that we can use .ToArraySegment
// and do an allocation free send before recycling it.
@ -122,7 +98,10 @@ public static bool UnpackMessage(NetworkReader messageReader, out int msgType)
}
}
internal static NetworkMessageDelegate MessageHandler<T>(Action<NetworkConnection, T> handler, bool requireAuthenication) where T : IMessageBase, new() => networkMessage =>
internal static NetworkMessageDelegate MessageHandler<T, C>(Action<C, T> handler, bool requireAuthenication)
where T : IMessageBase, new()
where C : NetworkConnection
=> (conn, reader, channelId) =>
{
// protect against DOS attacks if attackers try to send invalid
// data packets to crash the server/client. there are a thousand
@ -139,29 +118,30 @@ public static bool UnpackMessage(NetworkReader messageReader, out int msgType)
T message = default;
try
{
if (requireAuthenication && !networkMessage.conn.isAuthenticated)
if (requireAuthenication && !conn.isAuthenticated)
{
// message requires authentication, but the connection was not authenticated
Debug.LogWarning($"Closing connection: {networkMessage.conn}. Received message {typeof(T)} that required authentication, but the user has not authenticated yet");
networkMessage.conn.Disconnect();
Debug.LogWarning($"Closing connection: {conn}. Received message {typeof(T)} that required authentication, but the user has not authenticated yet");
conn.Disconnect();
return;
}
message = networkMessage.ReadMessage<T>();
message = typeof(T).IsValueType ? default(T) : new T();
message.Deserialize(reader);
}
catch (Exception exception)
{
Debug.LogError("Closed connection: " + networkMessage.conn + ". This can happen if the other side accidentally (or an attacker intentionally) sent invalid data. Reason: " + exception);
networkMessage.conn.Disconnect();
Debug.LogError("Closed connection: " + conn + ". This can happen if the other side accidentally (or an attacker intentionally) sent invalid data. Reason: " + exception);
conn.Disconnect();
return;
}
finally
{
// TODO: Figure out the correct channel
NetworkDiagnostics.OnReceive(message, networkMessage.channelId, networkMessage.reader.Length);
NetworkDiagnostics.OnReceive(message, channelId, reader.Length);
}
handler(networkMessage.conn, message);
handler((C)conn, message);
};
}
}

View File

@ -19,138 +19,6 @@ public virtual void Deserialize(NetworkReader reader) { }
public virtual void Serialize(NetworkWriter writer) { }
}
#region General Typed Messages
// Deprecated 11/20/2019
[Obsolete("Create your own message class instead")]
public class StringMessage : MessageBase
{
public string value;
public StringMessage() { }
public StringMessage(string v)
{
value = v;
}
public override void Deserialize(NetworkReader reader)
{
value = reader.ReadString();
}
public override void Serialize(NetworkWriter writer)
{
writer.WriteString(value);
}
}
// Deprecated 11/20/2019
[Obsolete("Create your own message class instead")]
public class ByteMessage : MessageBase
{
public byte value;
public ByteMessage() { }
public ByteMessage(byte v)
{
value = v;
}
public override void Deserialize(NetworkReader reader)
{
value = reader.ReadByte();
}
public override void Serialize(NetworkWriter writer)
{
writer.WriteByte(value);
}
}
// Deprecated 11/20/2019
[Obsolete("Create your own message class instead")]
public class BytesMessage : MessageBase
{
public byte[] value;
public BytesMessage() { }
public BytesMessage(byte[] v)
{
value = v;
}
public override void Deserialize(NetworkReader reader)
{
value = reader.ReadBytesAndSize();
}
public override void Serialize(NetworkWriter writer)
{
writer.WriteBytesAndSize(value);
}
}
// Deprecated 11/20/2019
[Obsolete("Create your own message class instead")]
public class IntegerMessage : MessageBase
{
public int value;
public IntegerMessage() { }
public IntegerMessage(int v)
{
value = v;
}
public override void Deserialize(NetworkReader reader)
{
value = reader.ReadPackedInt32();
}
public override void Serialize(NetworkWriter writer)
{
writer.WritePackedInt32(value);
}
}
// Deprecated 11/20/2019
[Obsolete("Create your own message class instead")]
public class DoubleMessage : MessageBase
{
public double value;
public DoubleMessage() { }
public DoubleMessage(double v)
{
value = v;
}
public override void Deserialize(NetworkReader reader)
{
value = reader.ReadDouble();
}
public override void Serialize(NetworkWriter writer)
{
writer.WriteDouble(value);
}
}
// Deprecated 11/20/2019
[Obsolete("Create your own message class instead")]
public class EmptyMessage : MessageBase
{
public override void Deserialize(NetworkReader reader) { }
public override void Serialize(NetworkWriter writer) { }
}
#endregion
#region Public System Messages
public struct ErrorMessage : IMessageBase
{
@ -188,32 +56,9 @@ public void Serialize(NetworkWriter writer) { }
public struct AddPlayerMessage : IMessageBase
{
// Deprecated 09/29/2019
/// <summary>
/// Obsolete: Create your own message instead. See <a href="../Guides/GameObjects/SpawnPlayerCustom.md">Custom Players</a>
/// </summary>
[Obsolete("Create your own message instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html")]
public byte[] value;
public void Deserialize(NetworkReader reader) { }
// Deprecated 09/29/2019
/// <summary>
/// Obsolete: Create your own message instead. See <a href="../Guides/GameObjects/SpawnPlayerCustom.md">Custom Players</a>
/// </summary>
[Obsolete("Create your own message instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html")]
public void Deserialize(NetworkReader reader)
{
value = reader.ReadBytesAndSize();
}
// Deprecated 09/29/2019
/// <summary>
/// Obsolete: Create your own message instead. See <a href="../Guides/GameObjects/SpawnPlayerCustom.md">Custom Players</a>
/// </summary>
[Obsolete("Create your own message instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html")]
public void Serialize(NetworkWriter writer)
{
writer.WriteBytesAndSize(value);
}
public void Serialize(NetworkWriter writer) { }
}
public struct RemovePlayerMessage : IMessageBase

View File

@ -102,13 +102,6 @@ protected void setSyncVarHookGuard(ulong dirtyBit, bool value)
syncVarHookGuard &= ~dirtyBit;
}
// Deprecated 04/07/2019
/// <summary>
/// Obsolete: Use <see cref="syncObjects"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use syncObjects instead.")]
protected List<SyncObject> m_SyncObjects => syncObjects;
/// <summary>
/// objects that can synchronize themselves, such as synclists
/// </summary>
@ -819,10 +812,6 @@ public virtual bool OnRebuildObservers(HashSet<NetworkConnection> observers, boo
return false;
}
// Deprecated 11/21/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Rename to OnSetHostVisibility instead.")]
public virtual void OnSetLocalVisibility(bool visible) { }
/// <summary>
/// Callback used by the visibility system for objects on a host.
/// <para>Objects on a host (with a local client) cannot be disabled or destroyed when they are not visibile to the local client. So this function is called to allow custom code to hide these objects. A typical implementation will disable renderer components on the object. This is only called on local clients on a host.</para>

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
namespace Mirror
@ -13,31 +12,14 @@ public enum ConnectState
Disconnected
}
// TODO make fully static after removing obsoleted singleton!
/// <summary>
/// This is a network client class used by the networking system. It contains a NetworkConnection that is used to connect to a network server.
/// <para>The <see cref="NetworkClient">NetworkClient</see> handle connection state, messages handlers, and connection configuration. There can be many <see cref="NetworkClient">NetworkClient</see> instances in a process at a time, but only one that is connected to a game server (<see cref="NetworkServer">NetworkServer</see>) that uses spawned objects.</para>
/// <para><see cref="NetworkClient">NetworkClient</see> has an internal update function where it handles events from the transport layer. This includes asynchronous connect events, disconnect events and incoming data from a server.</para>
/// <para>The <see cref="NetworkManager">NetworkManager</see> has a NetworkClient instance that it uses for games that it starts, but the NetworkClient may be used by itself.</para>
/// </summary>
public class NetworkClient
public static class NetworkClient
{
// Deprecated 03/25/2019
/// <summary>
/// Obsolete: Use <see cref="NetworkClient"/> directly.
/// <para>Singleton isn't needed anymore, all functions are static now. For example: NetworkClient.Send(message) instead of NetworkClient.singleton.Send(message).</para>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient directly. Singleton isn't needed anymore, all functions are static now. For example: NetworkClient.Send(message) instead of NetworkClient.singleton.Send(message).")]
public static NetworkClient singleton = new NetworkClient();
// Deprecated 03/25/2019
/// <summary>
/// A list of all the active network clients in the current process.
/// <para>This is NOT a list of all clients that are connected to the remote server, it is client instances on the local game.</para>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient directly instead. There is always exactly one client.")]
public static List<NetworkClient> allClients => new List<NetworkClient> { singleton };
/// <summary>
/// The registered network message handlers.
/// </summary>
@ -228,26 +210,6 @@ static void RemoveTransportHandlers()
Transport.activeTransport.OnClientError.RemoveListener(OnError);
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="Send{T}(T, int)"/> instead with no message id instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Send<T> instead with no message id instead")]
public static bool Send(short msgType, MessageBase msg)
{
if (connection != null)
{
if (connectState != ConnectState.Connected)
{
Debug.LogError("NetworkClient Send when not connected to a server");
return false;
}
return connection.Send(msgType, msg);
}
Debug.LogError("NetworkClient Send with no connection");
return false;
}
/// <summary>
/// This sends a network message with a message Id to the server. This message is sent on channel zero, which by default is the reliable channel.
/// <para>The message must be an instance of a class derived from MessageBase.</para>
@ -290,62 +252,6 @@ internal static void Update()
}
}
/* TODO use or remove
void GenerateConnectError(byte error)
{
Debug.LogError("Mirror Client Error Connect Error: " + error);
GenerateError(error);
}
void GenerateDataError(byte error)
{
NetworkError dataError = (NetworkError)error;
Debug.LogError("Mirror Client Data Error: " + dataError);
GenerateError(error);
}
void GenerateDisconnectError(byte error)
{
NetworkError disconnectError = (NetworkError)error;
Debug.LogError("Mirror Client Disconnect Error: " + disconnectError);
GenerateError(error);
}
void GenerateError(byte error)
{
int msgId = MessageBase.GetId<ErrorMessage>();
if (handlers.TryGetValue(msgId, out NetworkMessageDelegate msgDelegate))
{
ErrorMessage msg = new ErrorMessage
{
value = error
};
// write the message to a local buffer
NetworkWriter writer = new NetworkWriter();
msg.Serialize(writer);
NetworkMessage netMsg = new NetworkMessage
{
msgType = msgId,
reader = new NetworkReader(writer.ToArray()),
conn = connection
};
msgDelegate(netMsg);
}
}
*/
// Deprecated 10/05/2018
/// <summary>
/// Obsolete: Use <see cref="NetworkTime.rtt"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkTime.rtt instead")]
public static float GetRTT()
{
return (float)NetworkTime.rtt;
}
internal static void RegisterSystemHandlers(bool hostMode)
{
// host mode client / regular client react to some messages differently.
@ -375,30 +281,6 @@ internal static void RegisterSystemHandlers(bool hostMode)
RegisterHandler<SyncEventMessage>(ClientScene.OnSyncEventMessage);
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="RegisterHandler{T}(Action{NetworkConnection, T}, bool)"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use RegisterHandler<T> instead")]
public static void RegisterHandler(int msgType, NetworkMessageDelegate handler)
{
if (handlers.ContainsKey(msgType))
{
if (LogFilter.Debug) Debug.Log("NetworkClient.RegisterHandler replacing " + handler + " - " + msgType);
}
handlers[msgType] = handler;
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="RegisterHandler{T}(Action{NetworkConnection, T}, bool)"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use RegisterHandler<T> instead")]
public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handler)
{
RegisterHandler((int)msgType, handler);
}
/// <summary>
/// Register a handler for a particular message type.
/// <para>There are several system message types which you can add handlers for. You can also add your own message types.</para>
@ -413,7 +295,7 @@ public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handl
{
if (LogFilter.Debug) Debug.Log("NetworkClient.RegisterHandler replacing " + handler + " - " + msgType);
}
handlers[msgType] = MessagePacker.MessageHandler<T>(handler, requireAuthentication);
handlers[msgType] = MessagePacker.MessageHandler(handler, requireAuthentication);
}
/// <summary>
@ -428,26 +310,6 @@ public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handl
RegisterHandler((NetworkConnection _, T value) => { handler(value); }, requireAuthentication);
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="UnregisterHandler{T}"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use UnregisterHandler<T> instead")]
public static void UnregisterHandler(int msgType)
{
handlers.Remove(msgType);
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="UnregisterHandler{T}"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use UnregisterHandler<T> instead")]
public static void UnregisterHandler(MsgType msgType)
{
UnregisterHandler((int)msgType);
}
/// <summary>
/// Unregisters a network message handler.
/// </summary>
@ -475,15 +337,5 @@ public static void Shutdown()
// supposed to be shut down too!
Transport.activeTransport.ClientDisconnect();
}
// Deprecated 03/22/2019
/// <summary>
/// Obsolete: Call <see cref="Shutdown"/> instead. There is only one client.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Call Shutdown() instead. There is only one client.")]
public static void ShutdownAll()
{
Shutdown();
}
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
namespace Mirror
@ -62,23 +61,6 @@ public abstract class NetworkConnection : IDisposable
/// </summary>
public float lastMessageTime;
/// <summary>
/// Obsolete: use <see cref="identity"/> instead
/// </summary>
// Deprecated 09/18/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkConnection.identity instead")]
public NetworkIdentity playerController
{
get
{
return identity;
}
internal set
{
identity = value;
}
}
/// <summary>
/// The NetworkIdentity for this connection.
/// </summary>
@ -103,18 +85,6 @@ internal set
/// </remarks>
public bool logNetworkMessages;
// this is always true for regular connections, false for local
// connections because it's set in the constructor and never reset.
// Deprecated 02/26/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("isConnected will be removed because it's pointless. A NetworkConnection is always connected.")]
public bool isConnected { get; protected set; }
// this is always 0 for regular connections, -1 for local
// connections because it's set in the constructor and never reset.
// Deprecated 02/26/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("hostId will be removed because it's not needed ever since we removed LLAPI as default. It's always 0 for regular connections and -1 for local connections. Use connection.GetType() == typeof(NetworkConnection) to check if it's a regular or local connection.")]
public int hostId = -1;
/// <summary>
/// Creates a new NetworkConnection with the specified address
/// </summary>
@ -129,10 +99,6 @@ internal NetworkConnection()
internal NetworkConnection(int networkConnectionId)
{
connectionId = networkConnectionId;
#pragma warning disable 618
isConnected = true;
hostId = 0;
#pragma warning restore 618
}
~NetworkConnection()
@ -167,42 +133,6 @@ internal void SetHandlers(Dictionary<int, NetworkMessageDelegate> handlers)
messageHandlers = handlers;
}
// Deprecated 04/09/2019
/// <summary>
/// Obsolete: Use <see cref="NetworkClient.RegisterHandler{T}"/> or <see cref="NetworkServer.RegisterHandler{T}"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient/NetworkServer.RegisterHandler<T> instead")]
public void RegisterHandler(short msgType, NetworkMessageDelegate handler)
{
if (messageHandlers.ContainsKey(msgType))
{
if (LogFilter.Debug) Debug.Log("NetworkConnection.RegisterHandler replacing " + msgType);
}
messageHandlers[msgType] = handler;
}
// Deprecated 04/09/2019
/// <summary>
/// Obsolete: Use <see cref="NetworkClient.UnregisterHandler{T}"/> and <see cref="NetworkServer.UnregisterHandler{T}"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient/NetworkServer.UnregisterHandler<T> instead")]
public void UnregisterHandler(short msgType)
{
messageHandlers.Remove(msgType);
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: use <see cref="Send{T}(T, int)"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("use Send<T>(msg, channelId) instead")]
public bool Send(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable)
{
// pack message and send
byte[] message = MessagePacker.PackMessage(msgType, msg);
return Send(new ArraySegment<byte>(message), channelId);
}
/// <summary>
/// This sends a network message with a message ID on the connection. This message is sent on channel zero, which by default is the reliable channel.
/// </summary>
@ -282,29 +212,11 @@ internal void RemoveObservers()
visList.Clear();
}
// Deprecated 04/03/2019
/// <summary>
/// Obsolete: Use <see cref="InvokeHandler(int, NetworkReader, int)"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use InvokeHandler<T> instead")]
public bool InvokeHandlerNoData(int msgType)
{
return InvokeHandler(msgType, null, -1);
}
internal bool InvokeHandler(int msgType, NetworkReader reader, int channelId)
{
if (messageHandlers.TryGetValue(msgType, out NetworkMessageDelegate msgDelegate))
{
NetworkMessage message = new NetworkMessage
{
msgType = msgType,
reader = reader,
conn = this,
channelId = channelId
};
msgDelegate(message);
msgDelegate(this, reader, channelId);
return true;
}
Debug.LogError("Unknown message ID " + msgType + " " + this);

View File

@ -109,13 +109,6 @@ public sealed class NetworkIdentity : MonoBehaviour
[FormerlySerializedAs("m_ServerOnly")]
public bool serverOnly;
/// <summary>
/// Obsolete: Use <see cref="connectionToClient" /> instead
/// </summary>
// Deprecated 11/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use connectionToClient instead")]
public NetworkConnectionToClient clientAuthorityOwner => connectionToClient;
/// <summary>
/// The NetworkConnection associated with this NetworkIdentity. This is only valid for player objects on a local client.
/// </summary>
@ -189,13 +182,6 @@ internal set
// keep track of all sceneIds to detect scene duplicates
static readonly Dictionary<ulong, NetworkIdentity> sceneIds = new Dictionary<ulong, NetworkIdentity>();
/// <summary>
/// Obsolete: Use <see cref="GetSceneIdentity(ulong)" /> instead
/// </summary>
// Deprecated 01/23/2020
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use GetSceneIdentity instead")]
public static NetworkIdentity GetSceneIdenity(ulong id) => GetSceneIdentity(id);
/// <summary>
/// Gets the NetworkIdentity from the sceneIds dictionary with the corresponding id
/// </summary>
@ -655,9 +641,6 @@ internal void OnSetHostVisibility(bool visible)
{
try
{
#pragma warning disable 618
comp.OnSetLocalVisibility(visible); // remove later!
#pragma warning restore 618
comp.OnSetHostVisibility(visible);
}
catch (Exception e)
@ -1154,19 +1137,6 @@ public bool AssignClientAuthority(NetworkConnection conn)
return true;
}
// Deprecated 09/25/2019
/// <summary>
/// Obsolete: Use <see cref="RemoveClientAuthority()"/> instead
/// </summary>
/// <param name="conn">The connection of the client to remove authority for.</param>
/// <returns>True if authority is removed.</returns>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("NetworkConnection parameter is no longer needed and nothing is returned")]
public bool RemoveClientAuthority(NetworkConnection conn)
{
RemoveClientAuthority();
return true;
}
/// <summary>
/// Removes ownership for an object.
/// <para>This applies to objects that had authority set by AssignClientAuthority, or <see cref="NetworkServer.Spawn">NetworkServer.Spawn</see> with a NetworkConnection parameter included.</para>

View File

@ -162,28 +162,6 @@ public class NetworkManager : MonoBehaviour
[NonSerialized]
public bool clientLoadedScene;
// Deprecated 03/27/2019
/// <summary>
/// Obsolete: Use <see cref="NetworkClient.isConnected"/> instead
/// </summary>
/// <returns>Returns True if NetworkClient.isConnected</returns>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient.isConnected instead")]
public bool IsClientConnected()
{
return NetworkClient.isConnected;
}
// Deprecated 04/09/2019
/// <summary>
/// Obsolete: Use <see cref="isHeadless"/> instead.
/// <para>This is a static property now. This method will be removed by summer 2019.</para>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use isHeadless instead of IsHeadless()")]
public static bool IsHeadless()
{
return isHeadless;
}
/// <summary>
/// headless mode detection
/// </summary>
@ -197,14 +175,6 @@ public static bool IsHeadless()
// during FinishLoadScene.
public NetworkManagerMode mode { get; private set; }
// Deprecated 03/25/2019
/// <summary>
/// Obsolete: Use <see cref="NetworkClient"/> directly
/// <para>For example, use <c>NetworkClient.Send(message)</c> instead of <c>NetworkManager.client.Send(message)</c></para>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkClient directly, it will be made static soon. For example, use NetworkClient.Send(message) instead of NetworkManager.client.Send(message)")]
public NetworkClient client => NetworkClient.singleton;
#region Unity Callbacks
/// <summary>
@ -1131,7 +1101,7 @@ void OnServerReadyMessageInternal(NetworkConnection conn, ReadyMessage msg)
OnServerReady(conn);
}
void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage extraMessage)
void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage msg)
{
if (LogFilter.Debug) Debug.Log("NetworkManager.OnServerAddPlayer");
@ -1153,9 +1123,7 @@ void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage extraMes
return;
}
#pragma warning disable CS0618 // Type or member is obsolete
OnServerAddPlayer(conn, extraMessage);
#pragma warning restore CS0618 // Type or member is obsolete
OnServerAddPlayer(conn);
}
void OnServerRemovePlayerMessageInternal(NetworkConnection conn, RemovePlayerMessage msg)
@ -1287,17 +1255,6 @@ public virtual void OnServerReady(NetworkConnection conn)
NetworkServer.SetClientReady(conn);
}
// Deprecated 10/02/2019
/// <summary>
/// Obsolete: Override <see cref="OnServerAddPlayer(NetworkConnection)"/> instead.
/// <para>See <a href="../Guides/GameObjects/SpawnPlayerCustom.md">Custom Players</a> for details.</para>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Override OnServerAddPlayer(NetworkConnection conn) instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html for details.")]
public virtual void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)
{
OnServerAddPlayer(conn);
}
/// <summary>
/// Called on the server when a client adds a new player with ClientScene.AddPlayer.
/// <para>The default implementation for this function creates a new player object from the playerPrefab.</para>
@ -1421,16 +1378,6 @@ public virtual void OnClientError(NetworkConnection conn, int errorCode) { }
/// <param name="conn">Connection to the server.</param>
public virtual void OnClientNotReady(NetworkConnection conn) { }
// Deprecated 09/17/2019
/// <summary>
/// Obsolete: Use <see cref="OnClientChangeScene(string, SceneOperation, bool)"/> instead.).
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Override OnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling) instead")]
public virtual void OnClientChangeScene(string newSceneName)
{
OnClientChangeScene(newSceneName, SceneOperation.Normal, false);
}
// Deprecated 12/22/2019
/// <summary>
/// Obsolete: Use <see cref="OnClientChangeScene(string, SceneOperation, bool)"/> instead.).
@ -1488,24 +1435,10 @@ public virtual void OnStartHost() { }
/// </summary>
public virtual void OnStartServer() { }
// Deprecated 03/25/2019
/// <summary>
/// Obsolete: Use <see cref="OnStartClient()"/> instead of OnStartClient(NetworkClient client).
/// <para>All NetworkClient functions are static now, so you can use NetworkClient.Send(message) instead of client.Send(message) directly now.</para>
/// </summary>
/// <param name="client">The NetworkClient object that was started.</param>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use OnStartClient() instead of OnStartClient(NetworkClient client). All NetworkClient functions are static now, so you can use NetworkClient.Send(message) instead of client.Send(message) directly now.")]
public virtual void OnStartClient(NetworkClient client) { }
/// <summary>
/// This is invoked when the client is started.
/// </summary>
public virtual void OnStartClient()
{
#pragma warning disable CS0618 // Type or member is obsolete
OnStartClient(NetworkClient.singleton);
#pragma warning restore CS0618 // Type or member is obsolete
}
public virtual void OnStartClient() { }
/// <summary>
/// This is called when a server is stopped - including when a host is stopped.

View File

@ -1,26 +1 @@
namespace Mirror
{
public struct NetworkMessage
{
public int msgType;
public NetworkConnection conn;
public NetworkReader reader;
public int channelId;
public TMsg ReadMessage<TMsg>() where TMsg : IMessageBase, new()
{
// Normally I would just do:
// TMsg msg = new TMsg();
// but mono calls an expensive method Activator.CreateInstance
// For value types this is unnecesary, just use the default value
TMsg msg = typeof(TMsg).IsValueType ? default(TMsg) : new TMsg();
msg.Deserialize(reader);
return msg;
}
public void ReadMessage<TMsg>(TMsg msg) where TMsg : IMessageBase
{
msg.Deserialize(reader);
}
}
}
// file removed 03/17/2020

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
namespace Mirror
@ -256,27 +255,6 @@ static void SendToObservers<T>(NetworkIdentity identity, T msg, int channelId =
}
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="SendToAll{T}(T, int)"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use SendToAll<T> instead.")]
public static bool SendToAll(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable)
{
if (LogFilter.Debug) Debug.Log("Server.SendToAll id:" + msgType);
// pack message into byte[] once
byte[] bytes = MessagePacker.PackMessage((ushort)msgType, msg);
// send to all
bool result = true;
foreach (KeyValuePair<int, NetworkConnectionToClient> kvp in connections)
{
result &= kvp.Value.Send(new ArraySegment<byte>(bytes), channelId);
}
return result;
}
/// <summary>
/// Send a message structure with the given type number to all connected clients.
/// <para>This applies to clients that are ready and not-ready.</para>
@ -323,34 +301,6 @@ public static bool SendToAll<T>(T msg, int channelId = Channels.DefaultReliable)
}
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="SendToReady{T}(NetworkIdentity, T, int)"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use SendToReady<T> instead.")]
public static bool SendToReady(NetworkIdentity identity, short msgType, MessageBase msg, int channelId = Channels.DefaultReliable)
{
if (LogFilter.Debug) Debug.Log("Server.SendToReady msgType:" + msgType);
if (identity != null && identity.observers != null)
{
// pack message into byte[] once
byte[] bytes = MessagePacker.PackMessage((ushort)msgType, msg);
// send to all ready observers
bool result = true;
foreach (KeyValuePair<int, NetworkConnection> kvp in identity.observers)
{
if (kvp.Value.isReady)
{
result &= kvp.Value.Send(new ArraySegment<byte>(bytes), channelId);
}
}
return result;
}
return false;
}
/// <summary>
/// Send a message structure with the given type number to only clients which are ready.
/// <para>See Networking.NetworkClient.Ready.</para>
@ -561,30 +511,6 @@ static void OnError(int connectionId, Exception exception)
Debug.LogException(exception);
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="RegisterHandler{T}(Action{NetworkConnection, T}, bool)"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use RegisterHandler<T>(Action<NetworkConnection, T>, bool) instead.")]
public static void RegisterHandler(int msgType, NetworkMessageDelegate handler)
{
if (handlers.ContainsKey(msgType))
{
if (LogFilter.Debug) Debug.Log("NetworkServer.RegisterHandler replacing " + msgType);
}
handlers[msgType] = handler;
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="RegisterHandler{T}(Action{NetworkConnection, T}, bool)"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use RegisterHandler<T>(Action<NetworkConnection, T>, bool) instead.")]
public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handler)
{
RegisterHandler((int)msgType, handler);
}
/// <summary>
/// Register a handler for a particular message type.
/// <para>There are several system message types which you can add handlers for. You can also add your own message types.</para>
@ -614,26 +540,6 @@ public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handl
RegisterHandler<T>((_, value) => { handler(value); }, requireAuthentication);
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="UnregisterHandler{T}"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use UnregisterHandler<T> instead.")]
public static void UnregisterHandler(int msgType)
{
handlers.Remove(msgType);
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="UnregisterHandler{T}"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use UnregisterHandler<T> instead.")]
public static void UnregisterHandler(MsgType msgType)
{
UnregisterHandler((int)msgType);
}
/// <summary>
/// Unregisters a handler for a particular message type.
/// </summary>
@ -652,53 +558,6 @@ public static void ClearHandlers()
handlers.Clear();
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="NetworkConnection.Send{T}(T msg, int channelId = Channels.DefaultReliable)"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkConnection.Send<T>(msg) instead.")]
public static void SendToClient(int connectionId, int msgType, MessageBase msg)
{
if (connections.TryGetValue(connectionId, out NetworkConnectionToClient conn))
{
conn.Send(msgType, msg);
return;
}
Debug.LogError("Failed to send message to connection ID '" + connectionId + ", not found in connection list");
}
// Deprecated 10/22/2019
/// <summary>
/// Obsolete: Use <see cref="NetworkConnection.Send{T}(T msg, int channelId = Channels.DefaultReliable)"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use connection.Send(msg) instead")]
public static void SendToClient<T>(int connectionId, T msg) where T : IMessageBase
{
if (connections.TryGetValue(connectionId, out NetworkConnectionToClient conn))
{
conn.Send(msg);
return;
}
Debug.LogError("Failed to send message to connection ID '" + connectionId + ", not found in connection list");
}
// Deprecated 03/03/2019
/// <summary>
/// Obsolete: Use <see cref="SendToClientOfPlayer{T}(NetworkIdentity, T)"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use SendToClientOfPlayer<T> instead.")]
public static void SendToClientOfPlayer(NetworkIdentity identity, int msgType, MessageBase msg)
{
if (identity != null)
{
identity.connectionToClient.Send(msgType, msg);
}
else
{
Debug.LogError("SendToClientOfPlayer: player has no NetworkIdentity: " + identity.name);
}
}
/// <summary>
/// send this message to the player only
/// </summary>
@ -1156,17 +1015,6 @@ static bool VerifyCanSpawn(GameObject obj)
return true;
}
// Deprecated 11/23/2019
/// <summary>
/// Obsolete: Use <see cref="Spawn(GameObject, GameObject)"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Spawn(GameObject, GameObject) instead.")]
public static bool SpawnWithClientAuthority(GameObject obj, GameObject player)
{
Spawn(obj, player);
return true;
}
// Deprecated 11/23/2019
/// <summary>
/// This spawns an object like NetworkServer.Spawn() but also assigns Client Authority to the specified client.
@ -1192,28 +1040,6 @@ public static void Spawn(GameObject obj, GameObject player)
Spawn(obj, identity.connectionToClient);
}
// Deprecated 11/23/2019
/// <summary>
/// Use <see cref="Spawn(GameObject, NetworkConnection)"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Spawn(obj, connection) instead")]
public static bool SpawnWithClientAuthority(GameObject obj, NetworkConnection ownerConnection)
{
Spawn(obj, ownerConnection);
return true;
}
// Deprecated 11/23/2019
/// <summary>
/// Use <see cref="Spawn(GameObject, Guid, NetworkConnection)"/> instead
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Spawn(obj, assetId, connection) instead")]
public static bool SpawnWithClientAuthority(GameObject obj, Guid assetId, NetworkConnection ownerConnection)
{
Spawn(obj, assetId, ownerConnection);
return true;
}
/// <summary>
/// This spawns an object like NetworkServer.Spawn() but also assigns Client Authority to the specified client.
/// <para>This is the same as calling NetworkIdentity.AssignClientAuthority on the spawned object.</para>
@ -1299,20 +1125,6 @@ public static void UnSpawn(GameObject obj)
}
}
// Deprecated 01/15/2019
/// <summary>
/// Obsolete: Use <see cref="NetworkIdentity.spawned"/> instead.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use NetworkIdentity.spawned[netId] instead.")]
public static GameObject FindLocalObject(uint netId)
{
if (NetworkIdentity.spawned.TryGetValue(netId, out NetworkIdentity identity))
{
return identity.gameObject;
}
return null;
}
internal static bool ValidateSceneObject(NetworkIdentity identity)
{
if (identity.gameObject.hideFlags == HideFlags.NotEditable ||

View File

@ -1,5 +1,4 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Text;
using UnityEngine;
@ -85,135 +84,6 @@ public void WriteUInt64(ulong value)
}
public void WriteInt64(long value) => WriteUInt64((ulong)value);
#region Obsoletes
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteUInt16 instead")]
public void Write(ushort value) => this.WriteUInt16(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteUInt32 instead")]
public void Write(uint value) => WriteUInt32(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteUInt64 instead")]
public void Write(ulong value) => WriteUInt64(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteByte instead")]
public void Write(byte value) => stream.WriteByte(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteSByte instead")]
public void Write(sbyte value) => WriteByte((byte)value);
// write char the same way that NetworkReader reads it (2 bytes)
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteChar instead")]
public void Write(char value) => this.WriteUInt16((ushort)value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteBoolean instead")]
public void Write(bool value) => WriteByte((byte)(value ? 1 : 0));
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteInt16 instead")]
public void Write(short value) => this.WriteUInt16((ushort)value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteInt32 instead")]
public void Write(int value) => WriteUInt32((uint)value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteInt64 instead")]
public void Write(long value) => WriteUInt64((ulong)value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteSingle instead")]
public void Write(float value) => this.WriteSingle(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteDouble instead")]
public void Write(double value) => this.WriteDouble(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteDecimal instead")]
public void Write(decimal value) => this.WriteDecimal(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteString instead")]
public void Write(string value) => this.WriteString(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteBytes instead")]
public void Write(byte[] buffer, int offset, int count) => WriteBytes(buffer, offset, count);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector2 instead")]
public void Write(Vector2 value) => this.WriteVector2(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector3 instead")]
public void Write(Vector3 value) => this.WriteVector3(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector4 instead")]
public void Write(Vector4 value) => this.WriteVector4(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector2Int instead")]
public void Write(Vector2Int value) => this.WriteVector2Int(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteVector3Int instead")]
public void Write(Vector3Int value) => this.WriteVector3Int(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteColor instead")]
public void Write(Color value) => this.WriteColor(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteColor32 instead")]
public void Write(Color32 value) => this.WriteColor32(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteQuaternion instead")]
public void Write(Quaternion value) => this.WriteQuaternion(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteRect instead")]
public void Write(Rect value) => this.WriteRect(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WritePlane instead")]
public void Write(Plane value) => this.WritePlane(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteRay instead")]
public void Write(Ray value) => this.WriteRay(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteMatrix4x4 instead")]
public void Write(Matrix4x4 value) => this.WriteMatrix4x4(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteGuid instead")]
public void Write(Guid value) => this.WriteGuid(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteNetworkIdentity instead")]
public void Write(NetworkIdentity value) => this.WriteNetworkIdentity(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteTransform instead")]
public void Write(Transform value) => this.WriteTransform(value);
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteGameObject instead")]
public void Write(GameObject value) => this.WriteGameObject(value);
#endregion
}
@ -598,12 +468,5 @@ public static void WriteMessage<T>(this NetworkWriter writer, T msg) where T : I
{
msg.Serialize(writer);
}
// Deprecated 02/06/2020
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use WriteMessage<T> instead")]
public static void Write<T>(this NetworkWriter writer, T msg) where T : IMessageBase
{
WriteMessage(writer, msg);
}
}
}

View File

@ -22,10 +22,7 @@ public enum Operation : byte
OP_ADD,
OP_CLEAR,
OP_REMOVE,
OP_SET,
// Deprecated 12/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("SyncDictionaries now use OP_SET instead of OP_DIRTY")]
OP_DIRTY
OP_SET
}
struct Change

View File

@ -35,15 +35,6 @@ public class SyncListBool : SyncList<bool>
protected override bool DeserializeItem(NetworkReader reader) => reader.ReadBoolean();
}
// Original UNET name is SyncListStruct and original Weaver weavers anything
// that contains the name 'SyncListStruct', without considering the namespace.
// Deprecated 03/20/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use SyncList<MyStruct> instead")]
public class SyncListSTRUCT<T> : SyncList<T> where T : struct
{
public T GetItem(int i) => base[i];
}
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class SyncList<T> : IList<T>, IReadOnlyList<T>, SyncObject
{
@ -61,14 +52,8 @@ public enum Operation : byte
OP_ADD,
OP_CLEAR,
OP_INSERT,
// Deprecated 10/21/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Lists now pass OP_REMOVEAT")]
OP_REMOVE,
OP_REMOVEAT,
OP_SET,
// Deprecated 12/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Lists now use OP_SET instead of OP_DIRTY")]
OP_DIRTY
OP_SET
}
struct Change

View File

@ -2,7 +2,6 @@
// note: not all transports need a port, so add it to yours if needed.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
using UnityEngine.Events;
@ -154,18 +153,6 @@ public virtual void ClientConnect(Uri uri)
/// <returns>true if the client was kicked</returns>
public abstract bool ServerDisconnect(int connectionId);
/// <summary>
/// Obsolete: Use <see cref="ServerGetClientAddress(int)"/> instead
/// </summary>
// Removed 2/17/2019 and restored 3/2/2019
// Deprecated 03/02/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use ServerGetClientAddress(int connectionId) instead")]
public virtual bool GetConnectionInfo(int connectionId, out string address)
{
address = ServerGetClientAddress(connectionId);
return true;
}
/// <summary>
/// Get the client address
/// </summary>

View File

@ -1,12 +1,11 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using UnityEngine;
namespace Mirror
{
// Handles network messages on client and server
public delegate void NetworkMessageDelegate(NetworkMessage netMsg);
public delegate void NetworkMessageDelegate(NetworkConnection conn, NetworkReader reader, int channelId);
// Handles requests to spawn objects on the client
public delegate GameObject SpawnDelegate(Vector3 position, Guid assetId);
@ -24,45 +23,6 @@ public enum MirrorInvokeType
SyncEvent
}
// built-in system network messages
// original HLAPI uses short, so let's keep short to not break packet header etc.
// => use .ToString() to get the field name from the field value
// => we specify the short values so it's easier to look up opcodes when debugging packets
// Deprecated 03/03/2019
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use Send<T> with no message id instead")]
public enum MsgType : short
{
// internal system messages - cannot be replaced by user code
ObjectDestroy = 1,
Rpc = 2,
Owner = 4,
Command = 5,
SyncEvent = 7,
UpdateVars = 8,
SpawnPrefab = 3,
SpawnSceneObject = 10,
SpawnStarted = 11,
SpawnFinished = 12,
ObjectHide = 13,
LocalClientAuthority = 15,
// public system messages - can be replaced by user code
Connect = 32,
Disconnect = 33,
Error = 34,
Ready = 35,
NotReady = 36,
AddPlayer = 37,
RemovePlayer = 38,
Scene = 39,
// time synchronization
Ping = 43,
Pong = 44,
Highest = 47
}
public enum Version
{
Current = 1

View File

@ -8,11 +8,11 @@ namespace Mirror.Tests
public class LocalConnectionTest
{
class MyMessage : MessageBase
/*class MyMessage : MessageBase
{
public int id;
public string name;
}
}*/
ULocalConnectionToClient connectionToClient;
ULocalConnectionToServer connectionToServer;
@ -33,7 +33,7 @@ public void Disconnect()
connectionToServer.Disconnect();
}
[Test]
/*[Test]
public void ServerToClientTest()
{
Assert.That(connectionToClient.address, Is.EqualTo("localhost"));
@ -46,7 +46,7 @@ public void ServerToClientTest()
bool invoked = false;
void handler(NetworkMessage msg)
void handler(NetworkConnection conn, NetworkReader reader, int channelId)
{
MyMessage received = msg.ReadMessage<MyMessage>();
Assert.That(received.id, Is.EqualTo(3));
@ -63,9 +63,9 @@ void handler(NetworkMessage msg)
connectionToServer.Update();
Assert.True(invoked, "handler should have been invoked");
}
}*/
[Test]
/*[Test]
public void ClientToServerTest()
{
Assert.That(connectionToServer.address, Is.EqualTo("localhost"));
@ -78,7 +78,7 @@ public void ClientToServerTest()
bool invoked = false;
void handler(NetworkMessage msg)
void handler(NetworkConnection conn, NetworkReader reader, int channelId)
{
MyMessage received = msg.ReadMessage<MyMessage>();
Assert.That(received.id, Is.EqualTo(3));
@ -95,7 +95,7 @@ void handler(NetworkMessage msg)
connectionToServer.Update();
Assert.True(invoked, "handler should have been invoked");
}
}*/
[Test]
public void ClientToServerFailTest()

View File

@ -227,27 +227,6 @@ public void ReadyMessageTest()
fresh.Deserialize(new NetworkReader(writerData));
}
[Obsolete("The field we are testing will go away")]
[Test]
public void AddPlayerMessageTest()
{
// try setting value with constructor
AddPlayerMessage message = new AddPlayerMessage
{
value = new byte[]{1,2}
};
// serialize
NetworkWriter writer = new NetworkWriter();
message.Serialize(writer);
byte[] writerData = writer.ToArray();
// deserialize the same data - do we get the same result?
AddPlayerMessage fresh = new AddPlayerMessage();
fresh.Deserialize(new NetworkReader(writerData));
Assert.That(fresh.value, Is.EqualTo(message.value));
}
[Test]
public void RemovePlayerMessageTest()
{

View File

@ -580,7 +580,7 @@ public void AssignAndRemoveClientAuthority()
owner.connectionToServer = new ULocalConnectionToServer();
int spawnCalled = 0;
owner.connectionToServer.SetHandlers(new Dictionary<int, NetworkMessageDelegate>{
{ MessagePacker.GetId<SpawnMessage>(), (msg => ++spawnCalled) }
{ MessagePacker.GetId<SpawnMessage>(), ((conn, reader, channelId) => ++spawnCalled) }
});
// assigning authority should only work on server.
@ -1254,7 +1254,7 @@ public void ServerUpdate()
int ownerCalled = 0;
owner.connectionToServer.SetHandlers(new Dictionary<int, NetworkMessageDelegate>
{
{ MessagePacker.GetId<UpdateVarsMessage>(), (msg => ++ownerCalled) }
{ MessagePacker.GetId<UpdateVarsMessage>(), ((conn, reader, channelId) => ++ownerCalled) }
});
identity.connectionToClient = owner;
@ -1266,7 +1266,7 @@ public void ServerUpdate()
int observerCalled = 0;
observer.connectionToServer.SetHandlers(new Dictionary<int, NetworkMessageDelegate>
{
{ MessagePacker.GetId<UpdateVarsMessage>(), (msg => ++observerCalled) }
{ MessagePacker.GetId<UpdateVarsMessage>(), ((conn, reader, channelId) => ++observerCalled) }
});
identity.observers[observer.connectionId] = observer;

View File

@ -743,7 +743,7 @@ public void SendToAllTest()
int called = 0;
connection.connectionToServer.SetHandlers(new Dictionary<int,NetworkMessageDelegate>()
{
{ MessagePacker.GetId<TestMessage>(), (msg => ++called) }
{ MessagePacker.GetId<TestMessage>(), ((conn, reader, channelId) => ++called) }
});
NetworkServer.AddConnection(connection);
@ -847,7 +847,7 @@ public void SendToClientOfPlayer()
int called = 0;
connection.connectionToServer.SetHandlers(new Dictionary<int,NetworkMessageDelegate>()
{
{ MessagePacker.GetId<TestMessage>(), (msg => ++called) }
{ MessagePacker.GetId<TestMessage>(), ((conn, reader, channelId) => ++called) }
});
NetworkServer.AddConnection(connection);
@ -922,7 +922,7 @@ public void ShowForConnection()
int called = 0;
connection.connectionToServer.SetHandlers(new Dictionary<int,NetworkMessageDelegate>()
{
{ MessagePacker.GetId<SpawnMessage>(), (msg => ++called) }
{ MessagePacker.GetId<SpawnMessage>(), ((conn, reader, channelId) => ++called) }
});
NetworkServer.AddConnection(connection);
@ -972,7 +972,7 @@ public void HideForConnection()
int called = 0;
connection.connectionToServer.SetHandlers(new Dictionary<int,NetworkMessageDelegate>()
{
{ MessagePacker.GetId<ObjectHideMessage>(), (msg => ++called) }
{ MessagePacker.GetId<ObjectHideMessage>(), ((conn, reader, channelId) => ++called) }
});
NetworkServer.AddConnection(connection);

View File

@ -78,12 +78,6 @@ public void TestCleanup()
#endregion
#region General tests
[Test]
public void InvalidType()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.AccessViolationException MirrorTest.MirrorTestPlayer/MyStruct::violatedPotato has unsupported type. Use a type supported by Mirror instead"));
}
[Test]
public void RecursionCount()
@ -92,36 +86,6 @@ public void RecursionCount()
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/Potato1 can't be serialized because it references itself"));
}
[Test]
public void ClientGuardWrongClass()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Client] System.Void MirrorTest.MirrorTestPlayer::CantClientGuardInThisClass() must be declared in a NetworkBehaviour"));
}
[Test]
public void ServerGuardWrongClass()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Server] System.Void MirrorTest.MirrorTestPlayer::CantServerGuardInThisClass() must be declared in a NetworkBehaviour"));
}
[Test]
public void GuardCmdWrongClass()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Server] System.Void MirrorTest.MirrorTestPlayer::CantServerGuardInThisClass() must be declared in a NetworkBehaviour"));
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Server] System.Void MirrorTest.MirrorTestPlayer::CantServerCallbackGuardInThisClass() must be declared in a NetworkBehaviour"));
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Client] System.Void MirrorTest.MirrorTestPlayer::CantClientGuardInThisClass() must be declared in a NetworkBehaviour"));
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [Client] System.Void MirrorTest.MirrorTestPlayer::CantClientCallbackGuardInThisClass() must be declared in a NetworkBehaviour"));
}
[Test]
public void JaggedArray()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.Int32[][] is an unsupported type. Jagged and multidimensional arrays are not supported"));
}
#endregion
#region SyncVar tests
@ -243,43 +207,6 @@ public void SyncListByteValid()
#endregion
#region SyncListStruct tests
[Test]
public void SyncListStructValid()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.False);
Assert.That(weaverErrors, Is.Empty);
}
[Test]
public void SyncListStructGenericGeneric()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/MyStructClass cannot have generic elements MirrorTest.MirrorTestPlayer/MyGenericStruct`1<System.Single>"));
}
[Test]
public void SyncListStructMemberGeneric()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: Cannot generate writer for generic type MirrorTest.MirrorTestPlayer/MyGenericStruct`1<System.Single>. Use a concrete type or provide a custom writer"));
}
[Test]
public void SyncListStructMemberInterface()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: Cannot generate writer for interface MirrorTest.MirrorTestPlayer/IPotato. Use a concrete type or provide a custom writer"));
}
[Test]
public void SyncListStructMemberBasicType()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/MyStructClass cannot have item of type MirrorTest.MirrorTestPlayer/MyStruct. Use a type supported by mirror instead"));
}
#endregion
#region NetworkBehaviour tests
[Test]
public void NetworkBehaviourValid()

View File

@ -1,23 +0,0 @@
using System;
using UnityEngine;
using Mirror;
namespace MirrorTest
{
class MirrorTestPlayer
{
// defining a SyncListStruct here will force Weaver to do work on this class
// which will then force it to check for Server / Client guards and fail
struct MyStruct
{
int potato;
float floatingpotato;
double givemetwopotatoes;
}
class MyStructClass : SyncListSTRUCT<MyStruct> {};
MyStructClass Foo;
[Client]
public void CantClientGuardInThisClass() {}
}
}

View File

@ -1,32 +0,0 @@
using System;
using UnityEngine;
using Mirror;
namespace MirrorTest
{
class MirrorTestPlayer
{
// defining a SyncListStruct here will force Weaver to do work on this class
// which will then force it to check for Server / Client guards and fail
struct MyStruct
{
int potato;
float floatingpotato;
double givemetwopotatoes;
}
class MyStructClass : SyncListSTRUCT<MyStruct> {};
MyStructClass Foo;
[Server]
public void CantServerGuardInThisClass() {}
[ServerCallback]
public void CantServerCallbackGuardInThisClass() {}
[Client]
public void CantClientGuardInThisClass() {}
[ClientCallback]
public void CantClientCallbackGuardInThisClass() {}
}
}

View File

@ -1,18 +0,0 @@
using System;
using UnityEngine;
using Mirror;
namespace MirrorTest
{
class MirrorTestPlayer : NetworkBehaviour
{
struct MyStruct
{
public AccessViolationException violatedPotato;
}
class MyStructClass : SyncListSTRUCT<MyStruct> {};
MyStructClass harpseals;
}
}

View File

@ -1,20 +0,0 @@
using System;
using UnityEngine;
using Mirror;
namespace MirrorTest
{
class MirrorTestPlayer : NetworkBehaviour
{
// defining a SyncListStruct here will force Weaver to do work on this class
// which will then force it to check for Server / Client guards and fail
struct MyStruct
{
public int[][] jaggedArray;
public float floatingpotato;
public double givemetwopotatoes;
}
class MyStructClass : SyncListSTRUCT<MyStruct> {};
MyStructClass Foo;
}
}

View File

@ -1,23 +0,0 @@
using System;
using UnityEngine;
using Mirror;
namespace MirrorTest
{
class MirrorTestPlayer
{
// defining a SyncListStruct here will force Weaver to do work on this class
// which will then force it to check for Server / Client guards and fail
struct MyStruct
{
int potato;
float floatingpotato;
double givemetwopotatoes;
}
class MyStructClass : SyncListSTRUCT<MyStruct> {};
MyStructClass Foo;
[Server]
public void CantServerGuardInThisClass() {}
}
}