コード例 #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");
            }
        }
コード例 #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && connection != null)
     {
         connection.Close();
         connection = null;
     }
 }
コード例 #3
0
 /// <summary>
 /// Subclass should call this to close the connection.
 /// </summary>
 protected void CloseConnection()
 {
     lock (ConnectionCreationLock)
     {
         if (connection != null)
         {
             connection.Close();
         }
         connection = null;
     }
 }
コード例 #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);
 }