MultiplexTransport: syntax for readability

This commit is contained in:
vis2k 2022-12-03 18:28:19 -05:00
parent 27a22620db
commit f4d4563a43

View File

@ -23,61 +23,46 @@ public void Awake()
public override void ClientEarlyUpdate()
{
foreach (Transport transport in transports)
{
transport.ClientEarlyUpdate();
}
}
public override void ServerEarlyUpdate()
{
foreach (Transport transport in transports)
{
transport.ServerEarlyUpdate();
}
}
public override void ClientLateUpdate()
{
foreach (Transport transport in transports)
{
transport.ClientLateUpdate();
}
}
public override void ServerLateUpdate()
{
foreach (Transport transport in transports)
{
transport.ServerLateUpdate();
}
}
void OnEnable()
{
foreach (Transport transport in transports)
{
transport.enabled = true;
}
}
void OnDisable()
{
foreach (Transport transport in transports)
{
transport.enabled = false;
}
}
public override bool Available()
{
// available if any of the transports is available
foreach (Transport transport in transports)
{
if (transport.Available())
{
return true;
}
}
return false;
}
@ -150,20 +135,14 @@ public override void ClientSend(ArraySegment<byte> segment, int channelId)
// transport 0 will produce connection ids [0, 3, 6, 9, ...]
// transport 1 will produce connection ids [1, 4, 7, 10, ...]
// transport 2 will produce connection ids [2, 5, 8, 11, ...]
int FromBaseId(int transportId, int connectionId)
{
return connectionId * transports.Length + transportId;
}
int FromBaseId(int transportId, int connectionId) =>
connectionId * transports.Length + transportId;
int ToBaseId(int connectionId)
{
return connectionId / transports.Length;
}
int ToBaseId(int connectionId) =>
connectionId / transports.Length;
int ToTransportId(int connectionId)
{
return connectionId % transports.Length;
}
int ToTransportId(int connectionId) =>
connectionId % transports.Length;
void AddServerCallbacks()
{
@ -257,9 +236,7 @@ public override void ServerStart()
public override void ServerStop()
{
foreach (Transport transport in transports)
{
transport.ServerStop();
}
}
#endregion
@ -288,9 +265,7 @@ public override int GetMaxPacketSize(int channelId = 0)
public override void Shutdown()
{
foreach (Transport transport in transports)
{
transport.Shutdown();
}
}
public override string ToString()