基于简单的 Hello World 示例,我在发布时将oncounter
主题替换为主题onhello
。这将意味着AppSession
订阅了它本身正在发布的主题。我猜它应该能够接收自己的消息,但看起来它没有。有没有办法做到这一点?
对于一个可重现的例子:
from twisted.internet.defer import inlineCallbacks
from autobahn.twisted.util import sleep
from autobahn.twisted.wamp import ApplicationSession
class AppSession(ApplicationSession):
@inlineCallbacks
def onJoin(self, details):
def onhello(msg):
print("event for 'onhello' received: {}".format(msg))
sub = yield self.subscribe(onhello, 'com.example.onhello')
counter = 0
while True:
yield self.publish('com.example.onhello', counter)
print("published to 'onhello' with counter {}".format(counter))
counter += 1
yield sleep(1)
运行后crossbar start
,我看到onhello
主题正在发布,但没有收到。