Packages
Multi-surface application runtime for Elixir. One TEA module renders to terminal, browser (LiveView), SSH, and MCP (agents). 30+ widgets, flexbox + CSS grid, AI agent runtime, distributed swarm with CRDTs, time-travel debugging, session recording, sandboxed REPL, and agentic commerce.
Current section
Files
Jump to
Current section
Files
lib/raxol_web/channels/user_socket.ex
defmodule RaxolWeb.UserSocket do
use Phoenix.Socket
# Channels
channel("terminal:*", RaxolWeb.TerminalChannel)
# Transports
transport :websocket, Phoenix.Transports.WebSocket
# transport :longpoll, Phoenix.Transports.LongPoll
@doc """
Identifies the socket connections.
Socket params are passed from the client and can
be used to verify and authenticate a user.
To connect, url: "ws://localhost:4000/socket/websocket?user_id=123"
"""
def connect(%{"user_id" => user_id} = _params, socket, _connect_info) do
Logger.info("Connecting user with string key user_id: #{user_id}")
{:ok, assign(socket, :user_id, user_id)}
end
# Handle atom keys (e.g., from tests)
def connect(%{user_id: user_id} = _params, socket, _connect_info) do
Logger.info("Connecting user with atom key user_id: #{user_id}")
{:ok, assign(socket, :user_id, user_id)}
end
def connect(_params, _socket, _connect_info) do
# Deny connections if user_id is not present or for other auth failures
:error
end
@doc """
Identifies the socket connections.
"""
def id(socket), do: "user_socket:" <> socket.assigns.user_id
end