/// <summary>
        /// Handles any connection that disconnects from a remote end point
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnConnectionClosed(object sender, HttpConnectionEventArgs e)
        {
            // trace the connection id and the command it received
            Trace.WriteLineIf(_verbose, string.Format("Disconnected connection '{0}'.", e.Connection.Id), MY_TRACE_CATEGORY);

            try
            {
                lock (_connections.InnerList.SyncRoot)
                {
                    // find the connection in our list that has disconnected
                    HttpConnection connection = _connections[e.Connection.Id];
                    if (connection != null)
                    {
                        // dispose of it
                        connection.Dispose();

                        // remove it from our connection list
                        _connections.Remove(connection);
                    }
                }
            }
            catch (Exception ex)
            {
                this.OnException(this, new ExceptionEventArgs(ex));
            }
        }
Beispiel #2
0
 /// <summary>
 /// Raises the Closed event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void OnClosed(object sender, HttpConnectionEventArgs e)
 {
     try
     {
         if (this.Closed != null)
         {
             this.Closed(sender, e);
         }
     }
     catch (ThreadAbortException)
     {
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex, MY_TRACE_CATEGORY);
     }
 }
        /// <summary>
        /// Handles any connection that connects to a remote end point
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnConnectionOpened(object sender, HttpConnectionEventArgs e)
        {
            // trace the connection id and the command it received
            Trace.WriteLineIf(_verbose, string.Format("Connected connection '{0}' from '{1}'.", e.Connection.Id, e.Connection.Socket.RemoteEndPoint), MY_TRACE_CATEGORY);

            try
            {
                lock (_connections.InnerList.SyncRoot)
                {
                    // track the connection
                    _connections.Add(e.Connection);
                }
            }
            catch (Exception ex)
            {
                this.OnException(this, new ExceptionEventArgs(ex));
            }
        }
		/// <summary>
		/// Raises the Closed event
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected virtual void OnClosed(object sender, HttpConnectionEventArgs e) 
		{
			try 
			{
				if (this.Closed != null)
					this.Closed(sender, e);
			}
			catch(ThreadAbortException)
			{
			}
			catch(Exception ex) 
			{
				Trace.WriteLine(ex, MY_TRACE_CATEGORY);
			}
		}
		/// <summary>
		/// Handles any connection that disconnects from a remote end point
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OnConnectionClosed(object sender, HttpConnectionEventArgs e)
		{

			// trace the connection id and the command it received
			Trace.WriteLineIf(_verbose, string.Format("Disconnected connection '{0}'.", e.Connection.Id), MY_TRACE_CATEGORY);

			try
			{
				lock(_connections.InnerList.SyncRoot)
				{
					// find the connection in our list that has disconnected
					HttpConnection connection = _connections[e.Connection.Id];
					if (connection != null)
					{
						// dispose of it
						connection.Dispose();

						// remove it from our connection list
						_connections.Remove(connection);
					}
				}
			}
			catch(Exception ex)
			{
				this.OnException(this, new ExceptionEventArgs(ex));
			}
		}  
		/// <summary>
		/// Handles any connection that connects to a remote end point
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OnConnectionOpened(object sender, HttpConnectionEventArgs e)
		{

			// trace the connection id and the command it received
			Trace.WriteLineIf(_verbose, string.Format("Connected connection '{0}' from '{1}'.", e.Connection.Id, e.Connection.Socket.RemoteEndPoint), MY_TRACE_CATEGORY);     

			try
			{
				lock(_connections.InnerList.SyncRoot)
				{
					// track the connection
					_connections.Add(e.Connection);
				}
			}
			catch(Exception ex)
			{
				this.OnException(this, new ExceptionEventArgs(ex));
			}
		}
		/// <summary>
		/// Intercepts the diconnection event from the connection
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OnInternalConnectionClosed(object sender, HttpConnectionEventArgs e)
		{
			// forward this event on through the connection manager
			this.OnConnectionClosed(sender, new AddressBookItemConnectionManagerEventArgs(this));
		}