-
Notifications
You must be signed in to change notification settings - Fork 457
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?
Changes from all commits
e02cad1
e28c904
486ab1c
a7745cb
1931fbb
3a06511
cff9df6
97c2c7a
acdfdcf
20abe4b
1f2a521
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,8 +49,11 @@ internal override void Send(NetworkBehaviour behaviour, ref RpcMessage message, | |
{ | ||
continue; | ||
} | ||
// In distributed authority mode, we send to target id 0 (which would be a DAHost) via the group | ||
if (clientId == NetworkManager.ServerClientId && !m_NetworkManager.DistributedAuthorityMode) | ||
// In distributed authority mode, we send to target id 0 (which would be a DAHost). | ||
// 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 commentThe 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 🙃 |
||
{ | ||
continue; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,6 +164,107 @@ internal NetworkTopologyTypes CurrentTopology() | |
{ | ||
return OnCurrentTopology(); | ||
} | ||
|
||
/// <summary> | ||
/// 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 commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
/// </remarks> | ||
public enum DisconnectEvents | ||
{ | ||
/// <summary> | ||
/// If transport has mapped its disconnect events, this event signifies that the transport closed the connection due to a locally invoked shutdown. | ||
/// </summary> | ||
TransportShutdown, | ||
/// <summary> | ||
/// If transport has mapped its disconnect events, this event signifies a graceful disconnect. | ||
/// </summary> | ||
Disconnected, | ||
/// <summary> | ||
/// If transport has mapped its disconnect events, this event signifies that the transport's connection to the endpoint has timed out and the connection was closed. | ||
/// </summary> | ||
ProtocolTimeout, | ||
/// <summary> | ||
/// If transport has mapped its disconnect events, this event signifies that the disconnect is due to the maximum number of failed connection attempts has been reached. | ||
/// </summary> | ||
MaxConnectionAttempts, | ||
/// <summary> | ||
/// If transport has mapped its disconnect events, this event signifies that the remote endpoint closed the connection. | ||
/// </summary> | ||
ClosedByRemote, | ||
/// <summary> | ||
/// If transport has mapped its disconnect events, this event signifies the local transport closed the incoming remote endpoint connection. | ||
/// </summary> | ||
ClosedRemoteConnection, | ||
/// <summary> | ||
/// If transport has mapped its disconnect events, this event signifies that the connection was closed due to an authentication failure. | ||
/// </summary> | ||
AuthenticationFailure, | ||
/// <summary> | ||
/// If transport has mapped its disconnect events, this event signifies that a lower-level (unkown) transport error occurred. | ||
/// </summary> | ||
ProtocolError, | ||
} | ||
|
||
/// <summary> | ||
/// If the transport has implemented disconnection event mapping, then this will be set to the most recent disconnection event. | ||
/// </summary> | ||
public DisconnectEvents DisconnectEvent { get; private set; } | ||
|
||
/// <summary> | ||
/// If the transport has implemented disconnection event mapping and disconnection event message mapping, then this will contain | ||
/// the transport specific message associated with the disconnect event type. | ||
/// </summary> | ||
public string DisconnectEventMessage { get; private set; } | ||
|
||
/// <summary> | ||
/// This should be invoked by the <see cref="NetworkTransport"/> derived class when a transport level disconnect event occurs.<br /> | ||
/// It is up to the <see cref="NetworkTransport"/> derived class to create a map between the transport's disconnect events and the | ||
/// pre-defined <see cref="DisconnectEvents"/> enum values. | ||
/// </summary> | ||
/// <param name="disconnectEvent">The <see cref="DisconnectEvents"/> type to set.</param> | ||
/// <param name="message">An optional message override.</param> | ||
protected void SetDisconnectEvent(DisconnectEvents disconnectEvent, string message = null) | ||
{ | ||
DisconnectEvent = disconnectEvent; | ||
DisconnectEventMessage = string.Empty; | ||
|
||
if (message != null) | ||
{ | ||
DisconnectEventMessage = message; | ||
} | ||
else | ||
{ | ||
DisconnectEventMessage = OnGetDisconnectEventMessage(disconnectEvent); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Override this method to provide additional information about the disconnection event. | ||
/// </summary> | ||
/// <param name="disconnectEvent">The disconnect event to get from the <see cref="NetworkTransport"/> derived class.</param> | ||
/// <returns><see cref="string.Empty"/> as a default or if overridden the <see cref="string"/> returned.</returns> | ||
protected virtual string OnGetDisconnectEventMessage(DisconnectEvents disconnectEvent) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when the local <see cref="NetworkManager"/> forces the transport to close a remote connection. | ||
/// </summary> | ||
internal void ClosingRemoteConnection() | ||
{ | ||
SetDisconnectEvent(DisconnectEvents.ClosedRemoteConnection); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked just before the transport is shutdown. | ||
/// </summary> | ||
internal void ShuttingDown() | ||
{ | ||
SetDisconnectEvent(DisconnectEvents.TransportShutdown); | ||
} | ||
} | ||
|
||
/// <summary> | ||
|
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.
It looks like
transportClientId
isn't being used here