benoitc / dnssd_erlang

Erlang interface to Apple's Bonjour DNS Service Discovery implementation
Apache License 2.0
46 stars 16 forks source link

register event doesn't get the new service name #4

Closed benoitc closed 13 years ago

benoitc commented 13 years ago

When service name is incremented, new name is not available in events.

andrewtj commented 13 years ago

Can you provide some more details on this? On my system - https://gist.github.com/79421f9feeca73052064

benoitc commented 13 years ago

Hum figured it. When you register without settings the domain you get all registration events for this port & type. I wasn't paying attention to that. Sorry for the noise.

#!/usr/bin/env escript
%%! -pa dnssd_erlang/ebin

main(_) ->
    ok = dnssd:start(),
    {ok, _Ref1} = dnssd:register("test", "_test._tcp", 1),
    {ok, _Ref2} = dnssd:register("test", "_test._tcp", 2),
    main().

main() ->
    receive Term -> io:format("~p~n", [Term]) end,
    main().

result in:

$ ./test_issue4_dnssd.escript 
{dnssd,#Ref<0.0.0.57>,
       {register,add,{<<"test">>,<<"_test._tcp.">>,<<"local.">>}}}
{dnssd,#Ref<0.0.0.54>,
       {register,add,
                 {<<"test">>,<<"_test._tcp.">>,
                  <<"bchesneau.members.mac.com.">>}}}
{dnssd,#Ref<0.0.0.57>,
       {register,add,
                 {<<"test">>,<<"_test._tcp.">>,
                  <<"bchesneau.members.mac.com.">>}}}
{dnssd,#Ref<0.0.0.54>,
       {register,add,{<<"test (2)">>,<<"_test._tcp.">>,<<"local.">>}}}