这是我正在看的代码 .
from stomp import *
c = Connection([('127.0.0.1', 62613)])
c.set_listener('print', PrintingListener())
c.start()
c.set_listener('print', PrintingListener())
中的 'print'
用于什么?
我在这里检查了一些文档https://jasonrbriggs.github.io/stomp.py/stomp.html#module-stomp.listener
但是无法找到答案 .
大多数情况下,我只是想确保传入空字符串或多个侦听器的相同值是可以的 .
1 回答
set_listener
中的第一个参数只是侦听器实例的name . 稍后在调用get_listener和remove_listener(两者都采用name
参数)时可以使用相同的名称 . 如果要在单个连接上设置多个侦听器(即使用不同的名称),它也很有用 . The documentation指的是这样一句话:要清楚,空字符串(即
''
)是一个有效的名称,就像任何其他字符串一样 .