private void OnReceived(IAsyncResult result) { try { if (_client == null) { var client = (UdpClient)result.AsyncState; client.EndReceive(result, ref _endPoint); return; } var ea = new IncomingUdpMessageEventArgs(); ea.Message = Encoding.Default.GetString(_client.EndReceive(result, ref _endPoint)); OnIncomingMessage(ea); if (ea.Message.StartsWith("$SR")) { var args = new SearchResultEventArgs { Message = SRMessage.Parse(ea.Message) }; OnSearchResult(args); } } catch (Exception x) { } finally { if (_client != null) { _client.BeginReceive(OnReceived, null); } } }
private void OnSearchResult(SearchResultEventArgs e) { var handler = SearchResult; if (handler != null) { handler(this, e); } }
protected void OnPassiveSearchResult(SearchResultEventArgs e) { PassiveSearchResult?.Invoke(this, e); }