Example #1
0
 /*send all of the commands that there are to send to the flight simulator*/
 public void SendCommands()
 {
     //basic reader params
     using (NetworkStream ns = server.GetStream())
         using (BinaryWriter writer = new BinaryWriter(ns))
         {
             //run always on the background
             while (true)
             {
                 //run only while the server is connected
                 while (server.Connected)
                 {
                     //clear the command queue if it's not empty
                     while (!commands.IsEmpty())
                     {
                         //get the command and parse it to definitly end with \r\n
                         string commandToSend = Regex.Replace(commands.RemoveElement(), @"\n|\r", "") + "\r\n";
                         System.Diagnostics.Debug.WriteLine("sending = " + commandToSend);
                         //send the given command, converting it to a char array due to how BinaryWriter.Write works
                         writer.Write(commandToSend.ToCharArray());
                     }
                 }
             }
         }
 }
Example #2
0
        /*get a data point from the queue*/
        public string[] getData()
        {
            //get the raw data
            string dataBeforeConversion = commands.RemoveElement();

            //split the data up and return it
            string[] splitData = dataBeforeConversion.Split(',');
            //System.Diagnostics.Debug.WriteLine("Lon = " + splitData[0] + " Lat = " + splitData[1]);
            return(splitData);
        }