   end
   defp notify_cluster_for_new_user(_, false), do: nil
 
+  defp notify_cluster_for_removed_user(aliaz, id, true) do
+    Cluster.nodes
+    |> Enum.reject(fn node -> Config.alias() == node.alias end)
+    |> Enum.each(fn node ->
+      publish_message(%{alias: aliaz, id: id}, "REMOVE_USER", node.alias)
+    end)
+  end
+  defp notify_cluster_for_removed_user(_, _, false), do: nil
+
 end

        # Publish 'ADD_USER' message to other nodes when current node is master.
        notify_cluster_for_new_user(user, Config.is_master?)

      :node_missing ->
        Logger.error "Node with alias: '#{aliaz}' does not exist!"
    end
  end

  def remove_user(aliaz, id) do
    Cluster.remove_user aliaz, id

    # TODO Update rooms via web sockets.

    if Config.is_master? do
      Cluster.nodes
      |> Enum.reject(fn node -> Config.alias() == node.alias end)
      |> Enum.each(fn node ->
        publish_message(%{alias: aliaz, id: id}, "REMOVE_USER", node.alias)
      end)
    end
  end


    case Cluster.register_node(node) do
      :ok ->
        update_cluster(node, Config.is_master?)
        Logger.info "Node '#{node["alias"]}' registered to cluster."

      :node_exists ->
        Logger.error "Node '#{node["alias"]}' already exists."
    end
  end

