Esempio n. 1
0
        // TO DO: Better error reporting on this method.
        public void Shutdown()
        {
            if (Client != null)
            {
                try {
                    lock (ShutdownConnectionLock) {
                        if (NetworkStream != null)
                        {
                            NetworkStream.Close();
                            NetworkStream.Dispose();
                            NetworkStream = null;
                        }

                        Client.Close();
                        Client = null;

                        if (ConnectionClosed != null)
                        {
                            FrostbiteConnection.RaiseEvent(ConnectionClosed.GetInvocationList(), this);
                        }
                    }
                }
                catch (SocketException) {
                    // TO DO: Error reporting, possibly in a log file.
                }
                catch (Exception e) {
                    FrostbiteConnection.LogError("FrostbiteLayerConnection.Shutdown", "catch (Exception e)", e);
                }
            }
        }