feat: dynamically manage floors/rooms/tags
This commit is contained in:
@@ -27,6 +27,8 @@ defmodule Localiser.Localisation.Room.Server do
|
||||
|
||||
@impl true
|
||||
def init(room) do
|
||||
Phoenix.PubSub.subscribe(@pubsub, "rooms")
|
||||
|
||||
state = %__MODULE__{
|
||||
id: room.id,
|
||||
name: room.name,
|
||||
@@ -65,6 +67,19 @@ defmodule Localiser.Localisation.Room.Server do
|
||||
{:reply, state.occupants, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info({:room_updated, %{id: id} = room}, %{id: id} = state) do
|
||||
{:noreply, %{state |
|
||||
name: room.name,
|
||||
offset_x: room.offset_x || 0.0,
|
||||
offset_y: room.offset_y || 0.0,
|
||||
width: room.width || 0.0,
|
||||
height: room.height || 0.0
|
||||
}}
|
||||
end
|
||||
|
||||
def handle_info(_msg, state), do: {:noreply, state}
|
||||
|
||||
defp broadcast(room_id, occupants) do
|
||||
Phoenix.PubSub.broadcast(
|
||||
@pubsub,
|
||||
|
||||
Reference in New Issue
Block a user