Railway IPC UI v0.0.6 RailwayUiWeb.UserSocket View Source

Link to this section Summary

Functions

Identifies the socket connection.

Link to this section Functions

Link to this function

connect(params, socket, connect_info)

View Source

Callback implementation for Phoenix.Socket.connect/3.

Identifies the socket connection.

Socket IDs are topics that allow you to identify all sockets for a given user:

def id(socket), do: "users_socket:#{socket.assigns.user_id}"

Would allow you to broadcast a "disconnect" event and terminate all active sockets and channels for a given user:

MyApp.Endpoint.broadcast("users_socket:" <> user.id, "disconnect", %{})

Returning nil makes this socket anonymous.

Callback implementation for Phoenix.Socket.id/1.