Beispiel #1
0
        void HandleDisposed(UnrealAgentConnection c)
        {
            lock (ConnectionCreationLock)
            {
                if (c == connection)
                {
                    connection = null;
                }
            }

            var evt = Disconnected;

            if (evt == null)
            {
                return;
            }
            try
            {
                evt();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Unhandled exception");
            }
        }
Beispiel #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && connection != null)
     {
         connection.Close();
         connection = null;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Subclass should call this to close the connection.
 /// </summary>
 protected void CloseConnection()
 {
     lock (ConnectionCreationLock)
     {
         if (connection != null)
         {
             connection.Close();
         }
         connection = null;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Subclass should call this when a connection is starting.
 /// </summary>
 protected UnrealAgentConnection OnConnecting(TcpClient client)
 {
     lock (ConnectionCreationLock)
     {
         if (connection != null)
         {
             connection.Dispose();
         }
         connection = new UnrealAgentConnection(Log, client, HandleCommandBase, HandleDisposed);
     }
     return(connection);
 }