0
我想利用handle_info
跟踪参与用户的Presence
,但我注意到,handle_info
是从来没有所谓的,虽然用户succefully连接,并发送/收到的消息..为什么handle_info永远不会被调用?
defmodule App.UserChannel do
use App.Web, :channel
alias App.Presence
...
...
def handle_info(info, socket) do
IO.puts info
IO.puts "* * * "
{:ok, _} = Presence.track(socket, socket.assigns.user_id, %{
online_at: inspect(System.system_time(:seconds))
})
push socket, "presence_state", Presence.list(socket)
{:noreply, socket}
end
...
...
任何想法?
在服务器端,在App.UserChannel
内,我怎么知道某个用户是在线还是离线?
编辑
我需要有仙丹1.3有存在的工作?我在Elixir 1.2.6上,Phoenix(1.2.0-rc.1)
啊!是的,'发送自我,{:after_join,msg}'丢失,谢谢 – simo
你有没有试图检查一个特定的用户是否在线或不在服务器端? – simo
我还没有得到这一点,不。抱歉! –