public Athlete(Athlete _athlete) { firstName = _athlete.firstName; lastName = _athlete.lastName; gender = _athlete.gender; age = _athlete.age; status = _athlete.status; distanceCovered = _athlete.distanceCovered; startTime = _athlete.startTime; lastUpdatedTime = _athlete.lastUpdatedTime; finishTime = _athlete.finishTime; }
public void Finish(string message, IPEndPoint senderEndPoint) { var elements = SplitMessage(message); Athlete subject = new Athlete(); foreach (Athlete athlete in athleteList) { if (athlete.BibNumber == Int32.Parse(elements[1])) { athlete.CurrentStatus = AthleteRaceStatus.Finished; athlete.LastUpdatedTime = athlete.FinishedTime = Int32.Parse(elements[2]); subject = athlete; break; } } SendStatusUpdate(subject, senderEndPoint); }
public void Registered(string message, IPEndPoint senderEndPoint) { var elements = SplitMessage(message); Athlete newAthlete = new Athlete(); newAthlete.BibNumber = Int32.Parse(elements[1]); newAthlete.LastUpdatedTime = Int32.Parse(elements[2]); newAthlete.FirstName = elements[3]; newAthlete.LastName = elements[4]; newAthlete.Gender = elements[5]; newAthlete.Age = Int32.Parse(elements[6]); addAthlete(newAthlete); foreach (Client client in clientList) { SendMessage("Athlete," + elements[1] + ',' + elements[3] + ',' + elements[4] + ',' + elements[5] + ',' + elements[6], client.returnAddress); } }
public void Process(string[] Message, ref RaceManager _MyRaceManager, System.Net.IPEndPoint senderEndPoint) { Athlete MyAthlete = new Athlete(); MyAthlete.bibNumber = Convert.ToInt32(Message[1]); MyAthlete.startTime = Convert.ToDouble(Message[2]); MyAthlete.firstName = Message[3]; MyAthlete.lastName = Message[4]; MyAthlete.gender = Message[5]; MyAthlete.age = Convert.ToInt32(Message[6]); _MyRaceManager.MyRunners.Add(MyAthlete); string message = "Athlete," + MyAthlete.bibNumber + "," + MyAthlete.firstName + "," + MyAthlete.lastName + "," + MyAthlete.gender + "," + MyAthlete.age; foreach (var client in _MyRaceManager.MyClients) { _MyRaceManager.MyCommunicator.Send(message, client.MyEndPoint); } //here is where the communication logic would go }
public override void Update(string _Message, Athlete _MyAthlete) { if (_Message == "Attach") { if (!MyAthleteSubjects.Contains(_MyAthlete)) { MyAthleteSubjects.Add(_MyAthlete); } } if (_Message == "Detach") { if (MyAthleteSubjects.Contains(_MyAthlete)) { MyAthleteSubjects.Remove(_MyAthlete); } } //if (!MyAthleteSubjects.Contains(_MyAthlete)) //{ // MyAthleteSubjects.Add(_MyAthlete); //} // MyAthleteSubject = _MyAthlete; // Console.WriteLine(MyEndPoint.Address + " " + MyEndPoint.Port + " Got an update."); //Logic for communication would go here }
public abstract void Update(string _Message, Athlete _MyAthlete);
public void addAthlete(Athlete athlete) { athleteList.Add(athlete); }