 		...>    end)
 		iex> Channel.send(a, %Serverboards.MOM.Message{ id: 0, payload: "test"})
 		:ok
-
 	"""
 	def subscribe(channel, subscriber) when is_atom(channel) do
 		channel = Channel.Named.ensure_exists(channel)


	@doc ~S"""
	Subscribes to a channel.

	## Examples


	management.
	"""
	def handle_call({:send, msg}, _, state) do
		ok = if Enum.count(state.subscribers) == 0 and msg.error != :deadletter do
			Channel.send(:deadletter, %{msg | error: :deadletter})
			:nok
		else
			oks = for {_,f} <- state.subscribers do
				try do
					f.(msg)
					:ok
				rescue
					e ->
						Channel.send(:invalid, %Message{ msg | error: {e, System.stacktrace()}} )
						Logger.error("Error sending #{inspect msg} to #{inspect f}: #{inspect e}. Sent to :invalid messages channel.")
						Logger.error( Exception.format_stacktrace System.stacktrace )
						:nok
					end
				end
			if Enum.any?(oks, &(&1 != :ok)) do
				:nok
			else
				:ok
			end
		end
		{:reply, ok, state}
	end
end
