Current section

Files

Jump to
exmobiledevice lib ex_mobile_device diagnostics monitor.ex
Raw

lib/ex_mobile_device/diagnostics/monitor.ex

defmodule ExMobileDevice.Diagnostics.Monitor do
@moduledoc false
use GenServer
alias ExMobileDevice.Diagnostics.RestartManager
def start_link(args) do
GenServer.start_link(__MODULE__, args)
end
@impl GenServer
def init(_args) do
{:ok, %{}, {:continue, :subscribe}}
end
@impl GenServer
def handle_continue(:subscribe, state) do
case ExMobileDevice.Muxd.subscribe() do
{:ok, devices} -> devices |> Enum.each(&RestartManager.preconnect(&1))
end
{:noreply, state}
end
@impl GenServer
def handle_info({:exmobiledevice, {:device_attached, udid}}, state) do
RestartManager.preconnect(udid)
{:noreply, state}
end
def handle_info({:exmobiledevice, _}, state), do: {:noreply, state}
end