I'm using the Phoenix Chat Room Example and am having some problems with routing.
Inside the user_socket.ex file:
defmodule Chat.UserSocket do
use Phoenix.Socket
channel "rooms:*", Chat.RoomChannel
transport :websocket, Phoenix.Transports.WebSocket
def connect(_params, socket) do
{:ok, socket}
end
def id(_socket), do: nil
end
The problem I have is under the transport configuration.
transport :websocket, Phoenix.Transports.Websocket
Setting up a transport is basically like a directory. To connect through this socket, the client must have /websocket at the end of their URL. I am trying to gracefully remove that. I'm trying to get my websocket server to be accessed by server:port, with no directory requirements.
I found that the Chat.UserSocket module is called from lib/chat/endpoint.ex:
socket "/Balancer", Chat.UserSocket
Which this socket is also adding another required directory. So, to connect to the websocket server, you would need to append /Balancer/websocket to the URL. I am trying to remove that requirement. I could shorten the words, and use B/W, but that just seems unintuitive. Also, I'm fairly new to Elixir/Phoenix so I apologize for this sloppy question.