refactor: SendToObserver returns void (#1539)

We calculate a bool out of SendToObserver, but it is not clear what it is
and we don't use the result at all.  So just simplify things.
This commit is contained in:
Paul Pacheco 2020-03-04 01:52:17 -06:00 committed by GitHub
parent 549c729a07
commit 9c81c9b2eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -217,7 +217,7 @@ internal static void ActivateHostScene()
// this is like SendToReady - but it doesn't check the ready flag on the connection.
// this is used for ObjectDestroy messages.
static bool SendToObservers<T>(NetworkIdentity identity, T msg, int channelId = Channels.DefaultReliable) where T : IMessageBase
static void SendToObservers<T>(NetworkIdentity identity, T msg, int channelId = Channels.DefaultReliable) where T : IMessageBase
{
if (LogFilter.Debug) Debug.Log("Server.SendToObservers id:" + typeof(T));
@ -234,12 +234,11 @@ static bool SendToObservers<T>(NetworkIdentity identity, T msg, int channelId =
// -> makes code more complicated, but is HIGHLY worth it to
// avoid allocations, allow for multicast, etc.
connectionIdsCache.Clear();
bool result = true;
foreach (KeyValuePair<int, NetworkConnection> kvp in identity.observers)
{
// use local connection directly because it doesn't send via transport
if (kvp.Value is ULocalConnectionToClient)
result &= kvp.Value.Send(segment);
kvp.Value.Send(segment);
// gather all internet connections
else
connectionIdsCache.Add(kvp.Key);
@ -252,11 +251,8 @@ static bool SendToObservers<T>(NetworkIdentity identity, T msg, int channelId =
}
NetworkDiagnostics.OnSend(msg, Channels.DefaultReliable, segment.Count, identity.observers.Count);
return result;
}
}
return false;
}
// Deprecated 03/03/2019