From 9b2e7d09c7944010b8bba03627f582666e61b7ad Mon Sep 17 00:00:00 2001 From: vis2k Date: Mon, 10 May 2021 21:33:38 +0800 Subject: [PATCH] add comment --- Assets/Mirror/Runtime/NetworkConnection.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Assets/Mirror/Runtime/NetworkConnection.cs b/Assets/Mirror/Runtime/NetworkConnection.cs index 966df67c3..d611d3f5a 100644 --- a/Assets/Mirror/Runtime/NetworkConnection.cs +++ b/Assets/Mirror/Runtime/NetworkConnection.cs @@ -64,6 +64,23 @@ internal NetworkConnection(int networkConnectionId) : this() } /// Disconnects this connection. + // for future reference, here is how Disconnects work in Mirror. + // + // first, there are two types of disconnects: + // * voluntary: the other end simply disconnected + // * involuntary: server disconnects a client by itself + // + // UNET had special (complex) code to handle both cases differently. + // + // Mirror handles both cases the same way: + // * Disconnect is called from TOP to BOTTOM + // NetworkServer/Client -> NetworkConnection -> Transport.Disconnect() + // * Disconnect is handled from BOTTOM to TOP + // Transport.OnDisconnected -> ... + // + // in other words, calling Disconnect() does no cleanup whatsoever. + // it simply asks the transport to disconnect. + // then later the transport events will do the clean up. public abstract void Disconnect(); internal void SetHandlers(Dictionary handlers)