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()
|
||||
{
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user