-
-
Save shankardevy/d9616876a2dcf7c92c646e9c69186a07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MangoWeb.UserSocket do | |
use Phoenix.Socket | |
## Channels | |
channel "pos", MangoWeb.BotChannel | |
## Transports | |
transport :websocket, Phoenix.Transports.WebSocket | |
def connect(%{"token" => token}, socket) do | |
case Phoenix.Token.verify(socket, "socket_login", token) do | |
{:ok, user_id} -> | |
socket = assign(socket, :user_id, user_id) | |
{:ok, socket} | |
{:error, _} -> | |
:error | |
end | |
end | |
def id(_socket), do: nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment