/// <summary> /// Shutdown /// Flushes the internal messages /// Removes itself from the network update loop /// Disposes readers, writers, clears the queue history, and resets any parameters /// </summary> public void Shutdown() { //As long as this instance is using the pre-defined update stages if (!m_ProcessUpdateStagesExternally) { //Remove ourself from the network loop update system this.UnregisterAllNetworkUpdates(); } //We need to make sure all internal messages (i.e. object destroy) are sent m_RpcQueueProcessor.InternalMessagesSendAndFlush(); //Dispose of any readers and writers foreach (var queueHistorySection in QueueHistory) { foreach (var queueHistoryItemByStage in queueHistorySection.Value) { foreach (var queueHistoryItem in queueHistoryItemByStage.Value) { queueHistoryItem.Value.QueueWriter?.Dispose(); queueHistoryItem.Value.QueueReader?.Dispose(); queueHistoryItem.Value.QueueBuffer?.Dispose(); } } } //Clear history and parameters QueueHistory.Clear(); ClearParameters(); }
/// <summary> /// Flushes the internal messages /// Removes itself from the network update loop /// Disposes readers, writers, clears the queue history, and resets any parameters /// </summary> private void Shutdown() { #if UNITY_EDITOR || DEVELOPMENT_BUILD if (NetworkLog.CurrentLogLevel == LogLevel.Developer) { NetworkLog.LogInfo($"[Instance : {s_RpcQueueContainerInstances}] {nameof(RpcQueueContainer)} shutting down."); } #endif //As long as this instance is using the pre-defined update stages if (!m_ProcessUpdateStagesExternally) { //Remove ourself from the network loop update system this.UnregisterAllNetworkUpdates(); } //Make sure any remaining internal messages are sent before completely shutting down. m_RpcQueueProcessor.InternalMessagesSendAndFlush(NetworkManager.IsListening); //Dispose of any readers and writers foreach (var queueHistorySection in m_QueueHistory) { foreach (var queueHistoryItemByStage in queueHistorySection.Value) { foreach (var queueHistoryItem in queueHistoryItemByStage.Value) { queueHistoryItem.Value.QueueWriter?.Dispose(); queueHistoryItem.Value.QueueReader?.Dispose(); queueHistoryItem.Value.QueueBuffer?.Dispose(); } } } //Clear history and parameters m_QueueHistory.Clear(); ClearParameters(); }