Skip to content

Commit

Permalink
removed obsoletes (#1542)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
miwarnec committed Mar 17, 2020
1 parent 7bd1378 commit 4faec29
Show file tree
Hide file tree
Showing 35 changed files with 43 additions and 1,282 deletions.
3 changes: 2 additions & 1 deletion Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
5 changes: 0 additions & 5 deletions Assets/Mirror/Editor/NetworkAnimatorEditor.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Mirror/Editor/NetworkAnimatorEditor.cs.meta

This file was deleted.

1 change: 0 additions & 1 deletion Assets/Mirror/Editor/NetworkIdentityEditor.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Mirror/Editor/NetworkIdentityEditor.cs.meta

This file was deleted.

4 changes: 0 additions & 4 deletions Assets/Mirror/Editor/PreprocessorDefine.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Mirror/Editor/PreprocessorDefine.cs.meta

This file was deleted.

24 changes: 1 addition & 23 deletions Assets/Mirror/Runtime/ClientScene.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using UnityEngine;
using Guid = System.Guid;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
Expand Down
9 changes: 0 additions & 9 deletions Assets/Mirror/Runtime/CustomAttributes.cs
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
5 changes: 0 additions & 5 deletions Assets/Mirror/Runtime/LocalClient.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Mirror/Runtime/LocalClient.cs.meta

This file was deleted.

46 changes: 13 additions & 33 deletions Assets/Mirror/Runtime/MessagePacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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);
};
}
}
159 changes: 2 additions & 157 deletions Assets/Mirror/Runtime/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,138 +19,6 @@ public abstract class MessageBase : IMessageBase
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
{
Expand Down Expand Up @@ -188,32 +56,9 @@ public struct NotReadyMessage : IMessageBase

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;

// 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();
}
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 Serialize(NetworkWriter writer)
{
writer.WriteBytesAndSize(value);
}
public void Serialize(NetworkWriter writer) { }
}

public struct RemovePlayerMessage : IMessageBase
Expand Down

0 comments on commit 4faec29

Please sign in to comment.