I have the following function:
def join(id) do
if Node.connect(:"#{id}@127.0.0.1") do
send :global.whereis_name(id), {:join, id}
end
end
I receive the error:
(ArgumentError) argument error
:erlang.send(:undefined, ...
which I assume is because Node.connect
does some gathering of information and when I call :global.whereis_name
it has not finished yet. If I throw in a :timer.sleep(1000)
sure enough I don't get an error. Is there a more elegant solution? I would like repeat :global.whereis_name
until successful or a timeout is reached.
EDIT:
I should mention that I already have a node registered with the name id
.
You could do a :global.sync()
before :global.whereis_name(id)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With