public void Dispose()
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;
            if (_receiver != null)
            {
                _receiver.OnDiscovery -= _receiver_OnDiscovery;
            }


            _sender?.Stop();
            _receiver?.Stop();

            //_sender?.Dispose();
            //_receiver?.Dispose();

            _receiver = null;
            _sender   = null;
        }
        public ServiceDiscovererBase(string idendity, TIn message, IPEndPoint multiCastEndPoint = null)
        {
            Identity = message.Identity;
            Message  = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message));
            //ServiceTag = serviceTag;
            //ServiceName = serviceName;
            //ServiceEndPoint = serviceEndPoint;

            if (multiCastEndPoint == null)
            {
                _multiCastEndPoint = _defaultEndpoint;
            }
            else
            {
                _multiCastEndPoint = multiCastEndPoint;
            }

            _sender = new MultiCastSender(_multiCastEndPoint.Address.ToString(), _multiCastEndPoint.Port);

            _receiver = new MultiCastReceiver(_multiCastEndPoint.Address.ToString(), _multiCastEndPoint.Port);

            _receiver.OnDiscovery += _receiver_OnDiscovery;
        }