我不认为您可以在客户端中取消订阅,因为客户端被阻止了。我写了一个ruby脚本来展示如何使用退订。
require 'redis'r = Redis.newr.subscribe 'first' do |on| on.message do |e, d| puts e puts d r.unsubscribe endendputs "script was blocked?"
如果删除r.unsubscribe,该脚本将被阻止。并且您可以添加if子句以检查何时取消订阅client.ex:
r.unsubscribe if d == 'leave'



