private void OnTimerTick(object source, ElapsedEventArgs args) { //Console.WriteLine("Tick"); SerialDataHandler.getInstance().RequestStatus(); if (dataRequested) { SendMessage(ServerCommands.SendBikeData(latestBikeData)); //Console.WriteLine("Tock"); } }
public Connection(string ip, int port) { dataRequested = false; SerialDataHandler.getInstance().AddSubscriberToHandler(this); ConnectToServer(ip, port); latestBikeData = new BikeDataPackage("1970-01-01-00:00:00", "0", "0", "0", "0"); dataRequestTimer = new System.Timers.Timer(100); dataRequestTimer.Elapsed += OnTimerTick; dataRequestTimer.AutoReset = true; dataRequestTimer.Enabled = true; dataRequestTimer.Start(); client.GetStream().Flush(); SendMessage(ServerCommands.ClientType()); }