1 defmodule Pleroma.Web.UserSocket do
5 # channel "room:*", Pleroma.Web.RoomChannel
8 transport :websocket, Phoenix.Transports.WebSocket
9 # transport :longpoll, Phoenix.Transports.LongPoll
11 # Socket params are passed from the client and can
12 # be used to verify and authenticate a user. After
13 # verification, you can put default assigns into
14 # the socket that will be set for all channels, ie
16 # {:ok, assign(socket, :user_id, verified_user_id)}
18 # To deny connection, return `:error`.
20 # See `Phoenix.Token` documentation for examples in
21 # performing token verification on connect.
22 def connect(_params, socket) do
26 # Socket id's are topics that allow you to identify all sockets for a given user:
28 # def id(socket), do: "user_socket:#{socket.assigns.user_id}"
30 # Would allow you to broadcast a "disconnect" event and terminate
31 # all active sockets and channels for a given user:
33 # Pleroma.Web.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
35 # Returning `nil` makes this socket anonymous.
36 def id(_socket), do: nil