コード例 #1
0
        /// <summary>Resets the connection to its unconnected, initial state.</summary>
        private void Reset()
        {
            _resetRequested = false;

            if (ConnectionState != ClientState.Unconnected)
            {
                lock (this)
                {
                    Logger.Debug("Resetting session.");

                    OnDisconnecting(EventArgs.Empty);

                    Players            = null;
                    _localPlayerNumber = -1;
                    PlayerCount        = 0;
                    MaxPlayers         = 0;

                    if (_stream != null)
                    {
                        try
                        {
                            _stream.Flush();
                        }
                        catch (IOException ex)
                        {
                            Logger.WarnException("Failed flushing stream while closing connection.", ex);
                        }
                        _stream.Dispose();
                    }
                    if (_tcp != null)
                    {
                        _tcp.Close();
                    }
                    _stream = null;
                    _tcp    = null;

                    ConnectionState = ClientState.Unconnected;

                    OnDisconnected(EventArgs.Empty);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Flushes the underlying stream.
 /// </summary>
 /// <exception cref="System.IO.IOException">The underlying stream's Flush implementation caused an error.</exception>
 public void Flush()
 {
     _stream.Flush();
 }