   end
 
   def websocket_info({:nodes, ref, _foo}, req, state) do
+    {port, req} = :cowboy_req.port(req)
     ret = case ref do
       { :new, pid } -> "new node "<>:erlang.list_to_binary(pid)
       { :bye, pid } -> "bye node "<>:erlang.list_to_binary(pid)
       other -> syntax_error(other)
     end
-    nodes = ws_list
+    nodes = ws_list(port)
       |>Enum.map(fn(pid)->:erlang.pid_to_list(pid) end)
       |>:erlang.list_to_binary
     this_node = self()

  @doc """
  Gets the list of all active websocket PIDs from the ranch supervisor.
  """
  def ws_list() do
    Process.whereis(:ranch_sup) 
      |> Supervisor.which_children
      |> Enum.find(fn(x) -> elem(x,0) == {:ranch_listener_sup, :http} end)

        [current_function: {:cowboy_websocket, :handler_loop, 4}] ==
        Process.info(b,[:current_function]) end)
  end
  def ws_list() do
    []
  end

  def get_info(port) do
    Application.fetch_env!(:dynamite, :sites)
      |> Enum.find(fn(x) -> { _, [{:port, p}| _]} = x
          p == port
        end)
  end
  
  @doc """
  Broadcasts a `msg` to all active websockets supervised by ranch_conns_sup.
  """
  def ws_broadcast(type, msg, opts \\ []) do
    ws_list() |> Enum.map(fn(pid) -> Process.send(pid,{type,msg,opts},[]) end)
  end

  ## Errors
