breaking: obsolete Uri support

This commit is contained in:
vis2k 2021-05-13 13:19:18 +08:00
parent 089e5bbb59
commit 9bbbf51df5
18 changed files with 29 additions and 1 deletions

View File

@ -145,6 +145,7 @@ public static void Connect(string address)
}
/// <summary>Connect client to a NetworkServer by Uri.</summary>
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public static void Connect(Uri uri)
{
// Debug.Log("Client Connect: " + uri);

View File

@ -362,6 +362,7 @@ public void StartClient()
}
/// <summary>Starts the client, connects it to the server via Uri</summary>
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public void StartClient(Uri uri)
{
if (NetworkClient.active)

View File

@ -394,6 +394,7 @@ public static T[] ReadArray<T>(this NetworkReader reader)
return result;
}
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public static Uri ReadUri(this NetworkReader reader)
{
return new Uri(reader.ReadString());

View File

@ -413,6 +413,7 @@ public static void WriteGameObject(this NetworkWriter writer, GameObject value)
}
}
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public static void WriteUri(this NetworkWriter writer, Uri uri)
{
writer.WriteString(uri.ToString());

View File

@ -63,6 +63,7 @@ public override void ClientConnect(string address)
available.ClientConnect(address);
}
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override void ClientConnect(Uri uri)
{
foreach (Transport transport in transports)
@ -100,6 +101,7 @@ public override void ClientSend(ArraySegment<byte> segment, int channelId)
// right now this just returns the first available uri,
// should we return the list of all available uri?
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override Uri ServerUri() => available.ServerUri();
public override bool ServerActive()

View File

@ -139,6 +139,7 @@ void OnDisable()
}
// server
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override Uri ServerUri()
{
UriBuilder builder = new UriBuilder();

View File

@ -143,6 +143,7 @@ public override void ClientConnect(string address)
wrap.ClientConnect(address);
}
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override void ClientConnect(Uri uri)
{
wrap.OnClientConnected = OnClientConnected;
@ -167,6 +168,7 @@ public override void ClientSend(ArraySegment<byte> segment, int channelId)
SimulateSend(0, segment, channelId, latency, reliableClientToServer, unreliableClientToServer);
}
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override Uri ServerUri() => wrap.ServerUri();
public override bool ServerActive() => wrap.ServerActive();

View File

@ -48,6 +48,7 @@ public override void ServerStart()
public override void ServerSend(int connectionId, ArraySegment<byte> segment, int channelId) => inner.ServerSend(connectionId, segment, channelId);
public override void ServerDisconnect(int connectionId) => inner.ServerDisconnect(connectionId);
public override string ServerGetClientAddress(int connectionId) => inner.ServerGetClientAddress(connectionId);
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override Uri ServerUri() => inner.ServerUri();
#endregion
}

View File

@ -101,6 +101,7 @@ public override void ClientConnect(string address)
throw new ArgumentException("No transport suitable for this platform");
}
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override void ClientConnect(Uri uri)
{
foreach (Transport transport in transports)
@ -198,6 +199,7 @@ void AddServerCallbacks()
// for now returns the first uri,
// should we return all available uris?
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override Uri ServerUri()
{
return transports[0].ServerUri();

View File

@ -272,6 +272,7 @@ public override string ServerGetClientAddress(int connectionId)
return server.GetClientAddress(connectionId);
}
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override Uri ServerUri()
{
UriBuilder builder = new UriBuilder

View File

@ -123,6 +123,7 @@ public override bool Available()
// client
public override bool ClientConnected() => client.Connected;
public override void ClientConnect(string address) => client.Connect(address, port);
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override void ClientConnect(Uri uri)
{
if (uri.Scheme != Scheme)
@ -148,6 +149,7 @@ public override void ClientEarlyUpdate()
}
// server
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override Uri ServerUri()
{
UriBuilder builder = new UriBuilder();

View File

@ -55,6 +55,7 @@ public abstract class Transport : MonoBehaviour
public abstract void ClientConnect(string address);
/// <summary>Connects the client to the server at the Uri.</summary>
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public virtual void ClientConnect(Uri uri)
{
// By default, to keep backwards compatibility, just connect to the host

View File

@ -113,6 +113,7 @@ public override void ClientEarlyUpdate()
}
public override bool ServerActive() => serverActive;
[Obsolete("We are considering to remove Uri support, unless someone has a good reason to keep it.")]
public override Uri ServerUri() => throw new NotImplementedException();
public override void ServerStart() { serverActive = true; }
public override void ServerSend(int connectionId, ArraySegment<byte> segment, int channelId)

View File

@ -176,6 +176,7 @@ public void TestServerGetClientAddress(int id, string result)
[Test]
[TestCase("tcp4://localhost:7777")]
[TestCase("tcp4://example.com:7777")]
#pragma warning disable 618
public void TestServerUri(string address)
{
Uri uri = new Uri(address);
@ -185,6 +186,7 @@ public void TestServerUri(string address)
inner.Received(1).ServerUri();
}
#pragma warning restore 618
[Test]
public void TestClientConnectedCallback()

View File

@ -64,6 +64,7 @@ public void TestConnect()
}
// A Test behaves as an ordinary method
#pragma warning disable 618
[Test]
public void TestConnectFirstUri()
{
@ -76,9 +77,10 @@ public void TestConnectFirstUri()
transport1.Received().ClientConnect(uri);
transport2.DidNotReceive().ClientConnect(uri);
}
#pragma warning restore 61
// A Test behaves as an ordinary method
#pragma warning disable 618
[Test]
public void TestConnectSecondUri()
{
@ -96,6 +98,7 @@ public void TestConnectSecondUri()
transport.ClientConnect(uri);
transport2.Received().ClientConnect(uri);
}
#pragma warning restore 618
[Test]
public void TestConnected()

View File

@ -36,6 +36,7 @@ public void IsConnected()
Assert.That(NetworkClient.isConnected, Is.True);
}
#pragma warning disable 618
[Test]
public void ConnectUri()
{
@ -44,6 +45,7 @@ public void ConnectUri()
UpdateTransport();
Assert.That(NetworkClient.isConnected, Is.True);
}
#pragma warning restore 618
[Test]
public void DisconnectInHostMode()

View File

@ -133,6 +133,7 @@ public void GetStartPositionTest()
}
[Test]
#pragma warning disable 618
public void StartClientUriTest()
{
UriBuilder uriBuilder = new UriBuilder
@ -146,5 +147,6 @@ public void StartClientUriTest()
Assert.That(manager.isNetworkActive, Is.EqualTo(true));
Assert.That(manager.networkAddress, Is.EqualTo(uriBuilder.Uri.Host));
}
#pragma warning restore 618
}
}

View File

@ -904,6 +904,7 @@ public void TestWritingAndReading()
}
[Test]
#pragma warning disable 618
public void TestWritingUri()
{
@ -915,6 +916,7 @@ public void TestWritingUri()
NetworkReader reader = new NetworkReader(writer.ToArray());
Assert.That(reader.ReadUri(), Is.EqualTo(testUri));
}
#pragma warning restore 618
[Test]
public void TestList()