           new_queue = :queue.in_r({:unsubscribe, other_channels, receiver}, new_queue)
         end
 
+        send receiver, {:redix_pubsub, :unsubscribe, channel}
+
         %{s | queue: new_queue}
       _ ->
         raise "oops"

  end

  defp new_pubsub_msg(s, ["message", channel, message]) do
    recipients = s.pubsub_clients[channel]

    Enum.each recipients, fn(recipient) ->
      message = {:redix_pubsub, :message, channel, message}
      send(recipient, message)
    end

    s
  end

  defp new_pubsub_msg(s, ["pmessage", pattern, actual_channel, message]) do
    recipients = s.pubsub_clients[pattern]

    Enum.each recipients, fn(recipient) ->
      message = {:redix_pubsub, :pmessage, {pattern, actual_channel}, message}
      send(recipient, message)
    end

    s
  end



  defp new_pubsub_msg(s, ["punsubscribe", channel, _count]) do
    case :queue.out(s.queue) do
      {{:value, {:punsubscribe, [^channel|other_channels], receiver}}, new_queue} ->
        s = update_in s.pubsub_clients, fn(clients) ->
          Map.update!(clients, channel, &List.delete(&1, receiver))
        end

        if other_channels != [] do
          new_queue = :queue.in_r({:punsubscribe, other_channels, receiver}, new_queue)
        end

        send receiver, {:redix_pubsub, :punsubscribe, channel}

        %{s | queue: new_queue}
      _ ->
