中的第一个参数是什么连接设置侦听器()用于?

2024-09-27 00:21:47 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我要看的代码。你知道吗

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

但未能发现。你知道吗

大多数情况下,我只想确保在那里传递一个空字符串,或者为多个侦听器传递相同的值是可以的。你知道吗


Tags: 文件代码fromhttpsioimportgithubconnection
1条回答
网友
1楼 · 发布于 2024-09-27 00:21:47

set_listener中的第一个参数就是侦听器实例的name。以后调用^{}^{}(这两个函数都采用name参数)时,可以使用相同的名称。如果您想在一个连接上设置多个侦听器(即使用不同的名称),那么它也很有用。The documentation指的是这样一句话:

Note that listeners can be named so you can use more that one type of listener at the same time

要清楚的是,空字符串(即'')是一个有效的名称,就像任何其他字符串一样。你知道吗

相关问题 更多 >

    热门问题