3
基於簡單的Hello World示例,我在發佈時將oncounter
主題替換爲onhello
。這意味着AppSession
正在訂閱它自己發佈的主題。我猜它應該能夠接收它自己的消息,但它看起來沒有。有沒有辦法做到這一點?單個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
話題被髮表,但沒有收到。
好,我看,這不是很明顯......那現在是有道理的,謝謝! –