/// <summary>
 /// Invokes the HandleApplicationException handler, if exists.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnHandleApplicationException(TcpLibApplicationExceptionEventArgs e)
 {
     if (HandleApplicationException != null)
     {
         HandleApplicationException(this, e);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Fire the Connected event if it exists.
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnConnected(TcpServerEventArgs e)
        {
            if (Connected != null)
            {
                try
                {
                    Connected(this, e);
                }
                catch (Exception ex)
                {
                    // Close the connection if the application threw an exception that
                    // is caught here by the server.
                    e.ConnectionState.Close();
                    TcpLibApplicationExceptionEventArgs appErr = new TcpLibApplicationExceptionEventArgs(ex);

                    try
                    {
                        OnHandleApplicationException(appErr);
                    }
                    catch (Exception ex2)
                    {
                        // Oh great, the exception handler threw an exception!
                        System.Diagnostics.Trace.WriteLine(ex2.Message);
                    }
                }
            }
        }