Beispiel #1
0
            private void OnUdpReady(Socket socket)
            {
                string peerName;
                var    frame = ReceiveUdpFrame(out peerName);

                // If filter is set, check that beacon matches it
                bool isValid = false;

                if (m_filter != null)
                {
                    if (frame.MessageSize >= m_filter.MessageSize && Compare(frame, m_filter, m_filter.MessageSize))
                    {
                        isValid = true;
                    }
                }

                // If valid, discard our own broadcasts, which UDP echoes to us
                if (isValid && m_transmit != null)
                {
                    if (frame.MessageSize == m_transmit.MessageSize && Compare(frame, m_transmit, m_transmit.MessageSize))
                    {
                        isValid = false;
                    }
                }

                // If still a valid beacon, send on to the API
                if (isValid)
                {
                    m_pipe.SendMore(peerName).Send(frame.Buffer, frame.MessageSize);
                }
            }