static void Main(string[] args) { traffic Traffic = new traffic(MaxSize); #if DEBUG foreach (string statement in File.ReadAllLines("test.txt")) #else // Infinite loop that keeps reading the incoming traffic. string statement; while (!string.IsNullOrEmpty(statement = Console.ReadLine())) #endif { try { logStatement LogStatement = new logStatement(statement); #if DEBUG Console.WriteLine("Statement: " + LogStatement); #endif Traffic.Update(LogStatement.Url, LogStatement.Timestamp); if (LogStatement.Timestamp.Edge()) { Traffic.PrintStats(DisplaySize); } int trafficSize = Traffic.Check(LogStatement.Timestamp, TimeWindow); if ((trafficSize >= Threshold) && Traffic.Low) { Traffic.SetHigh(); Console.WriteLine("High traffic generated an alert - hits = {0}, triggered at {1}", Threshold, LogStatement.Timestamp); } if ((trafficSize < Threshold) && Traffic.High) { Traffic.SetLow(); Console.WriteLine("Low traffic generated recoveryhits = {0}, triggered at {1}", Threshold, LogStatement.Timestamp); } } catch (LogParseException e) { Console.WriteLine("Parse exception in Log Statement: " + e); } } }
void Awake() { spawner = FindObjectOfType <traffic> (); }