Beispiel #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();
        }
Beispiel #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);
     }
 }
Beispiel #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();
		} 
Beispiel #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);
			}
		}