예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        private void OnSearchResult(SearchResultEventArgs e)
        {
            var handler = SearchResult;

            if (handler != null)
            {
                handler(this, e);
            }
        }
예제 #3
0
 protected void OnPassiveSearchResult(SearchResultEventArgs e)
 {
     PassiveSearchResult?.Invoke(this, e);
 }