Ejemplo n.º 1
0
        public void sendMSG()
        {
            try
            {
                //---send the text---
                //---Find the length of data being sent---
                //byte[] bytesToSend = ASCIIEncoding.ASCII.GetBytes(textToSend);
                byte[] bytesToSend = ASCIIEncoding.ASCII.GetBytes(textToSend);
                System.Diagnostics.Debug.WriteLine("Sending : --" + textToSend + "--");
                nwStream.Write(bytesToSend, 0, bytesToSend.Length);

                if (TextToSend.Contains("INF"))
                {
                    readMsg();
                }

                if (TextToSend.Contains("LOP"))
                {
                    armLoop = new Thread(new ThreadStart(this.autoLoop));
                    armLoop.Start();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
        private void autoLoop()
        {
            while (!TextToSend.Contains("STP"))
            {
                byte[] bytesToSend = ASCIIEncoding.ASCII.GetBytes(textToSend);
                System.Diagnostics.Debug.WriteLine("Sending : --" + textToSend + "--");
                nwStream.Write(bytesToSend, 0, bytesToSend.Length);
                Thread.Sleep(5000);
            }

            byte[] bytesToS = ASCIIEncoding.ASCII.GetBytes(textToSend);
            System.Diagnostics.Debug.WriteLine("Sending : --" + textToSend + "--");
            nwStream.Write(bytesToS, 0, bytesToS.Length);
        }