-
Notifications
You must be signed in to change notification settings - Fork 455
fix: Disconnect event notifications #2390 #3551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop-2.0.0
Are you sure you want to change the base?
fix: Disconnect event notifications #2390 #3551
Conversation
Missed a parameter in the XML-API
My initial reaction to this is that it seems complex for what it is. Why couldn't we just impose on the I'm not sure I see the point of having all that mapping machinery in |
Fixing some minor test issues after the disconnect notification updates.
The approach you describe above I actually started with, but then I realized that I would have to decorate all places that implement the feature/update with UTP_TRANSPORT_2_4_ABOVE. Which would mean any custom Otherwise, users would always have to:
This way, it keeps the notification "transport neutral" while providing some mechanism to register a transport's disconnect events to the NGO (standardized) disconnect events. Does this make more sense? |
Not really. Maybe I'm missing something obvious, but I don't see how UTP would be required. To be clear, my suggestion is not for the disconnection events in Basically my proposal would be: abstract class NetworkTransport
{
public enum DisconnectEvents
{
...
}
public DisconnectEvents DisconnectEvent { get; protected set; }
public string DisconnectEventMessage { get; protected set; }
}
public class UnityTransport
{
...
case TransportEvent.Disconnect:
...
switch (reader.ReadByte())
{
case (byte)Error.Timeout:
DisconnectEvent = DisconnectEvents.ProtocolTimeout;
DisconnectEventMessage = "Connection has timed out.";
...
}
} And while I get the argument that we don't want every transport to have to implement mapping logic, I don't agree with it. The mapping logic will normally be simple enough that I don't believe it's worth abstracting away in |
Yeah...you have a good point about the amount of code and I wasn't 100% happy with my initial approach anyway.... I will tinker around with it and see if we can keep some of the non-event type related script while approaching it the way you described above. |
Regarding the new design:
|
@@ -520,6 +524,27 @@ internal void DataEventHandler(ulong transportClientId, ref ArraySegment<byte> p | |||
#endif | |||
} | |||
|
|||
private void GenerateDisconnectInformation(ulong clientId, ulong transportClientId, string reason = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private void GenerateDisconnectInformation(ulong clientId, ulong transportClientId, string reason = null) | |
private void GenerateDisconnectInformation(ulong clientId, string reason = null) |
It looks like transportClientId
isn't being used here
// We only add when there is a "DAHost" by | ||
// - excluding the server id when using client-server (i.e. !m_NetworkManager.DistributedAuthorityMode ) | ||
// - excluding if connected to the CMB backend service (i.e. we don't want to send to service as it will broadcast it back) | ||
if (clientId == NetworkManager.ServerClientId && (!m_NetworkManager.DistributedAuthorityMode || m_NetworkManager.CMBServiceConnection)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing as we can't reproduce this error I think it's maybe best to remove the changes in this file 🙃
/// The Netcode for GameObjects standardized disconnection event types. | ||
/// </summary> | ||
/// <remarks> | ||
/// <see cref="AddDisconnectEventMap"/> provides you with the ability to register the transport's disconnect event types with the local equivalent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AddDisconnectEventMap
function is defined in UnityTransport
rather than here in NetworkTransport
. From this code doc it looks like you've intended for it to live in NetworkTransport
?
This is a work in progress fix for issue #2390.
The fix is to provide a way for a NetworkTransport derived class implementation can register disconnect event maps to a standardized set of disconnect event types. This PR includes modifications to UnityTransport so it registers its internal disconnect events with the generic ones.
MTTB-1345
Changelog
NetworkTransport
derived custom transports can set the current disconnect event type (NetworkTransport.DisconnectEvents
) that, if implemented, will provide more details on why the transport disconnected.NetworkTransport.SetDisconnectEvent
that aNetworkTransport
derived custom transport can use to provide the disconnect event type that occurred.NetworkTransport.OnGetDisconnectEventMessage
that, when overridden, aNetworkTransport
derived custom transport can use to provide a customized extended message for eachNetworkTransport.DisconnectEvents
value.SendTo.NotMe
could cause an RPC to be delivered to the sender when connected to a live distributed authority session.UnityTransport
now handles setting the current disconnect notification type, via internalUnityTransportNotificationHandler
class, while also providing extended informational messages for each disconnect event type.Testing and Documentation
Backport
TBD if we want to bring all of this into v1.x.