/// <summary> /// Read one line at time, only read a line if it ends with \r\n. /// Reads a line of characters from the current stream and returns the data as a string. /// </summary> /// <returns>The next line from the input stream, or null if the end of the input stream is reached.</returns> public override string ReadLine() { string line = ""; int bytesRead = 0; bool foundEndOfData = false; char[] buffer = new char[1]; List <char> store = new List <char>(); int position = 0; // Start a new timeout clock. TimeoutClock timeoutClock = new TimeoutClock(5000); // While the end of the header data // has not been found. while (!foundEndOfData) { // Read a single byte from the stream // add the data to the store and re-assign. bytesRead = base.Read(buffer, 0, 1); // If data exists. if (bytesRead > 0) { // Each time data is read reset the timeout. timeoutClock.Reset(); store.Add(buffer[0]); // If the store contains the right // amount of data. if (store.Count > 1) { // If the end of the header data has been found // \r\n (13 10). if (store[position] == 10 && store[position - 1] == 13) { // The end of the header data has been found. foundEndOfData = true; break; } } // Increment the position. position++; } // If the timeout has bee reached then // break from the loop. if (timeoutClock.IsComplete()) { break; } } line = new string(store.ToArray()); return(line); }
public Game() { GameClock = new GameClock(); Horn = new Horn(); Period = new Period(); ShotClock = new ShotClock(); Possession = new Possession(); Home = new Team(); Guest = new Team(); TimeoutClock = new TimeoutClock(); }