so I have
socket.endpoint.subscribe("user_socket:" <> socket.id)
And when I try to broadcast to it
RealmWeb.Endpoint.broadcast(
"user_socket:#{player_state.socket_id}",
"quest completed",
%{})
I get this error
* (FunctionClauseError) no function clause matching in RealmWeb.WorldChannel.handle_info/2
(realm 0.1.0) lib/realm_web/channels/world_channel.ex:24: RealmWeb.WorldChannel.handle_info(%Phoenix.Socket.Broadcast{event: "quest completed", payload: %{}, topic: "user_socket:0fef857e-b003-4f86-b571-4a212be9beaa"}, %Phoenix.Socket{assigns: %{}, channel: RealmWeb.WorldChannel, channel_pid: #PID<0.661.0>, endpoint: RealmWeb.Endpoint, handler: RealmWeb.UserSocket, id: "0fef857e-b003-4f86-b571-4a212be9beaa", join_ref: "3", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: Realm.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "world:lobby", transport: :websocket, transport_pid: #PID<0.656.0>})
(phoenix 1.6.11) lib/phoenix/channel/server.ex:343: Phoenix.Channel.Server.handle_info/2
(stdlib 3.16.1) gen_server.erl:695: :gen_server.try_dispatch/4
(stdlib 3.16.1) gen_server.erl:771: :gen_server.handle_msg/6
(stdlib 3.16.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Broadcast{event: "quest completed", payload: %{}, topic: "user_socket:0fef857e-b003-4f86-b571-4a212be9beaa"}
State: %Phoenix.Socket{assigns: %{}, channel: RealmWeb.WorldChannel, channel_pid: #PID<0.661.0>, endpoint: RealmWeb.Endpoint, handler: RealmWeb.UserSocket, id: "0fef857e-b003-4f86-b571-4a212be9beaa", join_ref: "3", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: Realm.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "world:lobby", transport: :websocket, transport_pid: #PID<0.656.0>}
I don't know why this isn't working.
Why is it trying to do a handle_info
call. I am expecting the code to send a message directly to a specific client.