Beispiel #1
0
        private void OnReceive(IAsyncResult state)
        {
            EndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);

            if (PortOpen)
            {
                try
                {
                    var receiveState = (ArtNetReceiveData)(state.AsyncState);

                    if (receiveState != null)
                    {
                        receiveState.DataLength = EndReceiveFrom(state, ref remoteEndPoint);

                        //Protect against UDP loopback where we receive our own packets.
                        if (!LocalEndPoint.Equals(remoteEndPoint) && receiveState.Valid)
                        {
                            LastPacket = DateTime.Now;

                            ProcessPacket((IPEndPoint)remoteEndPoint, ArtNetPacket.Create(receiveState, CustomPacketCreator));
                        }
                    }
                }
                catch (Exception ex)
                {
                    OnUnhandledException(ex);
                }
                finally
                {
                    //Attempt to receive another packet.
                    StartReceive();
                }
            }
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            return(obj is Connection connection && LocalEndPoint.Equals(connection.LocalEndPoint) && RemoteEndPoint.Equals(connection.RemoteEndPoint));
        }
Beispiel #3
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            var connection = obj as Connection;

            return(LocalEndPoint.Equals(connection?.LocalEndPoint) && RemoteEndPoint.Equals(connection?.RemoteEndPoint));
        }
 public bool Equals(TcpConnection connection)
 {
     return(LocalEndPoint.Equals(connection.LocalEndPoint) && RemoteEndPoint.Equals(connection.RemoteEndPoint));
 }