Good day,
I am trying to setup channels on an existing project but to no avail. No error logged nor raised.
I have the below in place
mix.exs
{:phoenix, "~> 1.4.11"},
{:phoenix_pubsub, "~> 1.1"},
{:phoenix_ecto, "~> 4.0"},
{:ecto_sql, "~> 3.1"},
{:tds, "~> 2.1.1"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
app.js
import "phoenix_html"
import socket from "./socket.js"
socket.js
import {Socket} from "phoenix"
let socket = new Socket("/socket", {params: {token: window.userToken},logger: (kind, msg, data) => (
console.log(`${kind}: ${msg}`, data)
)})
and
socket.connect()
// Now that you are connected, you can join channels with a topic:
let channel = socket.channel("room:lobby", {})
channel.join()
.receive("ok", resp => { console.log("Joined successfully", resp) })
.receive("error", resp => { console.log("Unable to join", resp) })
export default socket
user_socket.js
channel "room:*", MyAppWeb.RoomChannel
However, even after following the documentation, the existing project doesnt respond to join the channel.