Skip to content

Commit caff1f6

Browse files
revert: Add NetworkAddress and NetworkPort properties to Transport. (#512) (#530)
This reverts commit feea3c1.
1 parent feea3c1 commit caff1f6

File tree

4 files changed

+9
-48
lines changed

4 files changed

+9
-48
lines changed

com.unity.multiplayer.mlapi/Runtime/Transports/MultiplexTransportAdapter.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
43
using MLAPI.Transports.Tasks;
54

65
namespace MLAPI.Transports.Multiplex
@@ -54,21 +53,6 @@ public enum ConnectionIdSpreadMethod
5453

5554
private byte m_LastProcessedTransportIndex;
5655

57-
/// <inheritdoc />
58-
public override string NetworkAddress
59-
{
60-
get => Transports.Any() ? Transports.First().NetworkAddress : default;
61-
set => Array.ForEach(Transports, t => t.NetworkAddress = value);
62-
}
63-
64-
/// <inheritdoc />
65-
public override ushort NetworkPort
66-
{
67-
get => Transports.Any() ? Transports.First().NetworkPort : default;
68-
set => Array.ForEach(Transports, t => t.NetworkPort = value);
69-
}
70-
71-
7256
public override bool IsSupported => true;
7357

7458
public override void DisconnectLocalClient()
@@ -343,4 +327,4 @@ public byte GetFirstSupportedTransportIndex()
343327

344328
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
345329
}
346-
}
330+
}

com.unity.multiplayer.mlapi/Runtime/Transports/NetworkTransport.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,6 @@ public abstract class NetworkTransport : MonoBehaviour
4141
/// </summary>
4242
public abstract ulong ServerClientId { get; }
4343

44-
/// <summary>
45-
/// Gets or sets the IP address the client uses to connect to the server.
46-
/// For transports which don't use an IP address to connect this property is used to pass a transport specific connection identifier such as a room name.
47-
/// </summary>
48-
public abstract string NetworkAddress { get; set; }
49-
50-
/// <summary>
51-
/// Gets or sets the port this transport should use for networking.
52-
/// In server/host mode this is the port on which the server is exposed.
53-
/// In client mode this is the port
54-
/// </summary>
55-
public abstract ushort NetworkPort { get; set; }
56-
5744
/// <summary>
5845
/// Gets a value indicating whether this <see cref="T:MLAPI.Transports.Transport"/> is supported in the current runtime context.
5946
/// This is used by multiplex adapters.

com.unity.multiplayer.mlapi/Runtime/Transports/UNET/UNetTransport.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using MLAPI.Logging;
77
using MLAPI.Profiling;
88
using MLAPI.Transports.Tasks;
9-
using UnityEngine;
109
using UnityEngine.Networking;
1110

1211
namespace MLAPI.Transports.UNET
@@ -27,10 +26,8 @@ public enum SendMode
2726
public int MaxConnections = 100;
2827
public int MaxSentMessageQueueSize = 128;
2928

30-
[SerializeField]
31-
string m_ConnectAddress = "127.0.0.1";
32-
[SerializeField]
33-
ushort m_ConnectPort = 7777;
29+
public string ConnectAddress = "127.0.0.1";
30+
public int ConnectPort = 7777;
3431
public int ServerListenPort = 7777;
3532
public int ServerWebsocketListenPort = 8887;
3633
public bool SupportWebsocket = false;
@@ -67,12 +64,6 @@ public enum SendMode
6764
private SocketTask m_ConnectTask;
6865
public override ulong ServerClientId => GetMLAPIClientId(0, 0, true);
6966

70-
/// <inheritdoc />
71-
public override string NetworkAddress { get { return m_ConnectAddress; } set { m_ConnectAddress = value; } }
72-
73-
/// <inheritdoc />
74-
public override ushort NetworkPort { get { return m_ConnectPort; } set { m_ConnectPort = value; } }
75-
7667
protected void LateUpdate()
7768
{
7869
if (UnityEngine.Networking.NetworkTransport.IsStarted && MessageSendMode == SendMode.Queued)
@@ -152,6 +143,7 @@ public override void Send(ulong clientId, ArraySegment<byte> data, NetworkChanne
152143
}
153144
}
154145

146+
155147
public void SendQueued(ulong clientId)
156148
{
157149
if (ProfilerEnabled)
@@ -169,11 +161,9 @@ public override NetworkEvent PollEvent(out ulong clientId, out NetworkChannel ne
169161
var eventType = RelayTransport.Receive(out int hostId, out int connectionId, out int channelId, m_MessageBuffer, m_MessageBuffer.Length, out int receivedSize, out byte error);
170162

171163
clientId = GetMLAPIClientId((byte)hostId, (ushort)connectionId, false);
172-
173164
receiveTime = UnityEngine.Time.realtimeSinceStartup;
174165

175166
var networkError = (NetworkError)error;
176-
177167
if (networkError == NetworkError.MessageToLong)
178168
{
179169
byte[] tempBuffer;
@@ -264,7 +254,7 @@ public override SocketTasks StartClient()
264254
var socketTask = SocketTask.Working;
265255

266256
m_ServerHostId = RelayTransport.AddHost(new HostTopology(GetConfig(), 1), false);
267-
m_ServerConnectionId = RelayTransport.Connect(m_ServerHostId, NetworkAddress, NetworkPort, 0, out byte error);
257+
m_ServerConnectionId = RelayTransport.Connect(m_ServerHostId, ConnectAddress, ConnectPort, 0, out byte error);
268258

269259
var connectError = (NetworkError)error;
270260

@@ -482,4 +472,4 @@ public IReadOnlyDictionary<string, int> GetTransportProfilerData()
482472
}
483473
}
484474
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
485-
#pragma warning restore 618
475+
#pragma warning restore 618

com.unity.multiplayer.mlapi/Tests/Runtime/RpcQueueTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public IEnumerator RpcQueueUnitTest()
3737
AllowRuntimeSceneChanges = true,
3838
EnableSceneManagement = false
3939
};
40-
unetTransport.NetworkAddress = "127.0.0.1";
41-
unetTransport.NetworkPort = 7777;
40+
unetTransport.ConnectAddress = "127.0.0.1";
41+
unetTransport.ConnectPort = 7777;
4242
unetTransport.ServerListenPort = 7777;
4343
unetTransport.MessageBufferSize = 65535;
4444
unetTransport.MaxConnections = 100;
@@ -107,4 +107,4 @@ public IEnumerator RpcQueueUnitTest()
107107
#endif
108108
}
109109
}
110-
}
110+
}

0 commit comments

Comments
 (0)