Hello, I need help with something and excuse me if it seems trivial since I’m still learning phoenix.
I have a simple LiveView to view a position of an object in 3D space, the position comes form an external socket here is how I handle the incoming position
def handle_in("new_msg", %{"x" => posX, "y"=> posY, "z" => posZ}, socket) do
GameLive.handle_event("new_position", %{"x" => posX, "y" => posY, "z" => posZ}, socket)
broadcast!(socket, "new_msg", %{x: posX, y: posY, z: posZ})
{:reply, {:ok, %{response: "Updated"}}, socket}
end
and here is how I handle the event
def handle_event("new_position", %{"x" => posX, "y" => posY, "z" => posZ}, socket) do
{:noreply, assign(socket, %{x: posX, y: posY, z: posZ})}
end
I get this error whenever I try to update the position
[error] GenServer #PID<0.481.0> terminating
** (FunctionClauseError) no function clause matching in Phoenix.LiveView.assign/2
(phoenix_live_view) lib/phoenix_live_view.ex:1252: Phoenix.LiveView.assign(%Phoenix.Socket{assigns: %{}, channel: GameviewWeb.RoomChannel, channel_pid: #PID<0.481.0>, endpoint: GameviewWeb.Endpoint, handler: GameviewWeb.UserSocket, id: nil, join_ref: "3", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: Gameview.PubSub, ref: "4", serializer: Phoenix.Socket.V2.JSONSerializer, topic: "room:lobby", transport: :websocket, transport_pid: #PID<0.478.0>}, %{x: 5, y: 5, z: 5})
What am I doing wrong?
Thanks in advance.