I’ve read through the docs and tried the examples, and so far so good. Everything worked as advertised. However, when I tried to experiment further, I got really confused.
How do I use /____/subscribe
and /____/unsubscribe
?
The docs state that these two channels have been created for me, but they don’t tell me how to use them. Is there an example anywhere of how to use these?
I actually tried to look for the Julia code that defines these channels, but I couldn’t find the code while searching through the GenieFramework/Genie.jl.
Channel Naming Confusion
In the docs, there was a channel defined on the Julia side like this:
channel("/____/echo") do
@info "Received: $(params(:payload))"
end
To send a message to it from the browser, one could do something like this:
Genie.WebChannels.sendMessageTo(
'____', 'echo', 'Hello!'
)
However, suppose there were a channel defined like this on the Julia side:
channel("/____/foo/bar") do
@info "foo/bar received: $(params(:payload))"
end
The JavaScript that was able to reach this channel was:
Genie.WebChannels.sendMessageTo(
'____', 'foo/bar', 'Hello!'
)
This makes me think that ____
is special. It also confuses me when it comes to the definition of “channel”. Is ____
a channel or is /____/foo/bar
a channel?
Cleaning Up Disconnected Clients
The docs say:
You should routinely
unsubscribe_disconnected_clients()
to free memory.
Is this a reasonable way to do that?
unsub = @task begin
while true
Genie.WebChannels.unsubscribe_disconnected_clients()
sleep(30)
end
end
schedule(unsub)
If anyone could provide even partial answers to these questions, I’d appreciate it.