Exemple #1
0
        private void Run()
        {
            IPEndPoint localEP = new IPEndPoint(IPAddress.Any, localPort);

            while (!stop)
            {
                try
                {
                    byte[] buffer       = this.udpClient.Receive(ref localEP);
                    string bufferString = null;
                    for (int i = 0; i < buffer.Length; i++)
                    {
                        bufferString += (char)buffer[i];
                    }
                    if (bufferString.Length > 0)
                    {
                        InputDetectedEventArgs e = new InputDetectedEventArgs(bufferString);
                        OnInputDetected(e);
                    }
                }
                catch (Exception f)
                {
                    throw(f);
                }
            }
            Console.WriteLine("Stop UDP");
            this.udpClient.Close();
        }
Exemple #2
0
 // The protected OnInputDetected method raises the event by invoking
 // the delegates. The sender is always "this", the current instance
 // of the class.
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnInputDetected(InputDetectedEventArgs e)
 {
     if (InputDetected != null)
     {
         // Invokes the delegates.
         InputDetected(this, e);
     }
 }
Exemple #3
0
		private void Run() 
		{ 
			IPEndPoint localEP = new IPEndPoint(IPAddress.Any, localPort);
			while(!stop) 
			{ 
				try 
				{ 
					byte[] buffer = this.udpClient.Receive(ref localEP); 					
					string bufferString = null;
					for (int i = 0; i < buffer.Length; i++)
					{
						bufferString += (char)buffer[i];
					}
					if (bufferString.Length > 0) 
					{
						InputDetectedEventArgs e = new InputDetectedEventArgs(bufferString);
						OnInputDetected(e);
					}
				} 
				catch (Exception f) 
				{ 
					throw(f);
				} 
			}
			Console.WriteLine ("Stop UDP");
			this.udpClient.Close();
		} 
Exemple #4
0
		// The protected OnInputDetected method raises the event by invoking 
		// the delegates. The sender is always "this", the current instance 
		// of the class.
		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		protected virtual void OnInputDetected(InputDetectedEventArgs e)
		{
			if (InputDetected != null) 
			{
				// Invokes the delegates. 
				InputDetected(this, e);
			}
		}