mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
MultiplexTransport: syntax for readability
This commit is contained in:
parent
27a22620db
commit
f4d4563a43
@ -23,61 +23,46 @@ public void Awake()
|
|||||||
public override void ClientEarlyUpdate()
|
public override void ClientEarlyUpdate()
|
||||||
{
|
{
|
||||||
foreach (Transport transport in transports)
|
foreach (Transport transport in transports)
|
||||||
{
|
|
||||||
transport.ClientEarlyUpdate();
|
transport.ClientEarlyUpdate();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ServerEarlyUpdate()
|
public override void ServerEarlyUpdate()
|
||||||
{
|
{
|
||||||
foreach (Transport transport in transports)
|
foreach (Transport transport in transports)
|
||||||
{
|
|
||||||
transport.ServerEarlyUpdate();
|
transport.ServerEarlyUpdate();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ClientLateUpdate()
|
public override void ClientLateUpdate()
|
||||||
{
|
{
|
||||||
foreach (Transport transport in transports)
|
foreach (Transport transport in transports)
|
||||||
{
|
|
||||||
transport.ClientLateUpdate();
|
transport.ClientLateUpdate();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ServerLateUpdate()
|
public override void ServerLateUpdate()
|
||||||
{
|
{
|
||||||
foreach (Transport transport in transports)
|
foreach (Transport transport in transports)
|
||||||
{
|
|
||||||
transport.ServerLateUpdate();
|
transport.ServerLateUpdate();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable()
|
void OnEnable()
|
||||||
{
|
{
|
||||||
foreach (Transport transport in transports)
|
foreach (Transport transport in transports)
|
||||||
{
|
|
||||||
transport.enabled = true;
|
transport.enabled = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDisable()
|
void OnDisable()
|
||||||
{
|
{
|
||||||
foreach (Transport transport in transports)
|
foreach (Transport transport in transports)
|
||||||
{
|
|
||||||
transport.enabled = false;
|
transport.enabled = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Available()
|
public override bool Available()
|
||||||
{
|
{
|
||||||
// available if any of the transports is available
|
// available if any of the transports is available
|
||||||
foreach (Transport transport in transports)
|
foreach (Transport transport in transports)
|
||||||
{
|
|
||||||
if (transport.Available())
|
if (transport.Available())
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
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 0 will produce connection ids [0, 3, 6, 9, ...]
|
||||||
// transport 1 will produce connection ids [1, 4, 7, 10, ...]
|
// transport 1 will produce connection ids [1, 4, 7, 10, ...]
|
||||||
// transport 2 will produce connection ids [2, 5, 8, 11, ...]
|
// transport 2 will produce connection ids [2, 5, 8, 11, ...]
|
||||||
int FromBaseId(int transportId, int connectionId)
|
int FromBaseId(int transportId, int connectionId) =>
|
||||||
{
|
connectionId * transports.Length + transportId;
|
||||||
return connectionId * transports.Length + transportId;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ToBaseId(int connectionId)
|
int ToBaseId(int connectionId) =>
|
||||||
{
|
connectionId / transports.Length;
|
||||||
return connectionId / transports.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ToTransportId(int connectionId)
|
int ToTransportId(int connectionId) =>
|
||||||
{
|
connectionId % transports.Length;
|
||||||
return connectionId % transports.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddServerCallbacks()
|
void AddServerCallbacks()
|
||||||
{
|
{
|
||||||
@ -257,9 +236,7 @@ public override void ServerStart()
|
|||||||
public override void ServerStop()
|
public override void ServerStop()
|
||||||
{
|
{
|
||||||
foreach (Transport transport in transports)
|
foreach (Transport transport in transports)
|
||||||
{
|
|
||||||
transport.ServerStop();
|
transport.ServerStop();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -288,9 +265,7 @@ public override int GetMaxPacketSize(int channelId = 0)
|
|||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
{
|
{
|
||||||
foreach (Transport transport in transports)
|
foreach (Transport transport in transports)
|
||||||
{
|
|
||||||
transport.Shutdown();
|
transport.Shutdown();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
Loading…
Reference in New Issue
Block a user