//====================================
        // ChannelReaderConsumer
        //====================================

        public void Consume(RawMessage message)
        {
            var incoming          = message.AsTextMessage();
            var serviceRegistered = ServiceRegistered.From(incoming);

            if (serviceRegistered.IsValid && _interest.InterestedIn(serviceRegistered.Name.Value))
            {
                _interest.InformDiscovered(
                    new ServiceRegistrationInfo(serviceRegistered.Name.Value,
                                                Location.From(serviceRegistered.Addresses)));
            }
            else
            {
                var serviceUnregistered = ServiceUnregistered.From(incoming);

                if (serviceUnregistered.IsValid && _interest.InterestedIn(serviceUnregistered.Name.Value))
                {
                    _interest.InformUnregistered(serviceUnregistered.Name.Value);
                }
                else
                {
                    ManageDirectoryChannel(incoming);
                }
            }
        }
Beispiel #2
0
    public void TestValidity()
    {
        var registerService = new ServiceRegistered(Name.Of("test-service"),
                                                    new[]
        {
            Address.From(Host.Of("1.2.3.4"), 111, AddressType.Main),
            Address.From(Host.Of("1.2.3.45"), 222, AddressType.Main),
        });

        Assert.True(registerService.IsValid);
        Assert.False(ServiceRegistered.From("blah").IsValid);
        Assert.True(ServiceRegistered.From(_textMessage).IsValid);
    }