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