projects/Extant_Networking/NetStreamConnection.cs
/// <summary>
/// Closes an engaged connection. Connection will still be considered 'Active' while incoming packets are still
/// stored in the buffer.
/// </summary>
Closes an engaged connection. Connection will still be considered 'Active' while incoming packets are still
stored in the buffer.
Closes an engaged connection . Connection will still be considered ' Active ' while incoming packets are still stored in the buffer .
public void Close(NetConnectionClosingReason closingReason = NetConnectionClosingReason.ClosedSelf, Exception unhandledException = null)
        {
            if (_isClosed)
                return;
            try
            {
                lock (_stream.Lock)
                {
                    _stream.Value.Close();
                    _unhandledException = unhandledException;
                    _isClosed = true;
                }
            }
            catch (Exception e)
            {
                Log.LogWarning("Exception while trying to close: " + e.ToString());
            }
            finally
            {
                if (_closingReason == NetConnectionClosingReason.None)
                    _closingReason = closingReason;
                _lifeTimer.Stop();
                Log.LogMessage("Closed [" + closingReason.ToString() + "]" + (unhandledException != null ? (" Exception: " + unhandledException.ToString()) : ""));
            }
        }
public void Close ( NetConnectionClosingReason closingReason = NetConnectionClosingReason . ClosedSelf , Exception unhandledException = null ) { if ( _isClosed ) return ; try { lock ( _stream . Lock ) { _stream . Value . Close ( ) ; _unhandledException = unhandledException ; _isClosed = true ; } } catch ( Exception e ) { Log . LogWarning ( " " + e . ToString ( ) ) ; } finally { if ( _closingReason == NetConnectionClosingReason . None ) _closingReason = closingReason ; _lifeTimer . Stop ( ) ; Log . LogMessage ( " " + closingReason . ToString ( ) + " " + ( unhandledException != null ? ( " " + unhandledException . ToString ( ) ) : " " ) ) ; } }
Closes an engaged connection.
Closes an engaged connection .
closingReason
NetConnectionClosingReason
unhandledException
Exception