mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkConnection.HandleBytes moved into TransportReceive
This commit is contained in:
parent
f68119d614
commit
06a334e6dd
@ -180,6 +180,39 @@ internal virtual bool SendBytes( byte[] bytes, int channelId = Channels.DefaultR
|
|||||||
return TransportSend(channelId, bytes, out byte error);
|
return TransportSend(channelId, bytes, out byte error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("hostId: {0} connectionId: {1} isReady: {2}", hostId, connectionId, isReady);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void AddToVisList(NetworkIdentity identity)
|
||||||
|
{
|
||||||
|
visList.Add(identity);
|
||||||
|
|
||||||
|
// spawn uv for this conn
|
||||||
|
NetworkServer.ShowForConnection(identity, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void RemoveFromVisList(NetworkIdentity identity, bool isDestroyed)
|
||||||
|
{
|
||||||
|
visList.Remove(identity);
|
||||||
|
|
||||||
|
if (!isDestroyed)
|
||||||
|
{
|
||||||
|
// hide uv for this conn
|
||||||
|
NetworkServer.HideForConnection(identity, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void RemoveObservers()
|
||||||
|
{
|
||||||
|
foreach (NetworkIdentity identity in visList)
|
||||||
|
{
|
||||||
|
identity.RemoveObserverInternal(this);
|
||||||
|
}
|
||||||
|
visList.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
// handle this message
|
// handle this message
|
||||||
// note: original HLAPI HandleBytes function handled >1 message in a while loop, but this wasn't necessary
|
// note: original HLAPI HandleBytes function handled >1 message in a while loop, but this wasn't necessary
|
||||||
// anymore because NetworkServer/NetworkClient.Update both use while loops to handle >1 data events per
|
// anymore because NetworkServer/NetworkClient.Update both use while loops to handle >1 data events per
|
||||||
@ -187,7 +220,7 @@ internal virtual bool SendBytes( byte[] bytes, int channelId = Channels.DefaultR
|
|||||||
// -> in other words, we always receive 1 message per Receive call, never two.
|
// -> in other words, we always receive 1 message per Receive call, never two.
|
||||||
// -> can be tested easily with a 1000ms send delay and then logging amount received in while loops here
|
// -> can be tested easily with a 1000ms send delay and then logging amount received in while loops here
|
||||||
// and in NetworkServer/Client Update. HandleBytes already takes exactly one.
|
// and in NetworkServer/Client Update. HandleBytes already takes exactly one.
|
||||||
protected void HandleBytes(byte[] buffer)
|
public virtual void TransportReceive(byte[] buffer)
|
||||||
{
|
{
|
||||||
// unpack message
|
// unpack message
|
||||||
NetworkReader reader = new NetworkReader(buffer);
|
NetworkReader reader = new NetworkReader(buffer);
|
||||||
@ -232,44 +265,6 @@ protected void HandleBytes(byte[] buffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return string.Format("hostId: {0} connectionId: {1} isReady: {2}", hostId, connectionId, isReady);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void AddToVisList(NetworkIdentity identity)
|
|
||||||
{
|
|
||||||
visList.Add(identity);
|
|
||||||
|
|
||||||
// spawn uv for this conn
|
|
||||||
NetworkServer.ShowForConnection(identity, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void RemoveFromVisList(NetworkIdentity identity, bool isDestroyed)
|
|
||||||
{
|
|
||||||
visList.Remove(identity);
|
|
||||||
|
|
||||||
if (!isDestroyed)
|
|
||||||
{
|
|
||||||
// hide uv for this conn
|
|
||||||
NetworkServer.HideForConnection(identity, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void RemoveObservers()
|
|
||||||
{
|
|
||||||
foreach (NetworkIdentity identity in visList)
|
|
||||||
{
|
|
||||||
identity.RemoveObserverInternal(this);
|
|
||||||
}
|
|
||||||
visList.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void TransportReceive(byte[] bytes)
|
|
||||||
{
|
|
||||||
HandleBytes(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool TransportSend(int channelId, byte[] bytes, out byte error)
|
public virtual bool TransportSend(int channelId, byte[] bytes, out byte error)
|
||||||
{
|
{
|
||||||
error = 0;
|
error = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user