stomp.py on_before_message 方法有什么用?
What is stomp.py on_before_message method used for?
我正在使用来自 stomp.py, and it has the method: on_before_message
的 Class - PrintingListener
。
我不确定为什么调用这个方法。我无法理解这个定义。有人可以解释一下这个方法的用法和调用时间吗?
根据 stomp.py documentation,PrintingListener
"just prints all interactions between the client and server." on_before_message
是 stomp.py 定义的方法之一,因此 PrintingListener
调用它。
The stomp.py API documentation 关于 on_before_message
的说法:
Called by the STOMP connection before a message is returned to the client app. Returns a tuple containing the headers and body (so that implementing listeners can pre-process the content).
Parameters:
- headers (dict) – the message headers
- body – the message body
如此处所述,on_before_message
被调用“ 以便实现侦听器可以 pre-process 内容 。”如果您不需要 pre-process 消息的内容(即 headers 或 body),那么您可以忽略此方法。
顾名思义,on_before_message
在 on_message
之前立即被调用。
我正在使用来自 stomp.py, and it has the method: on_before_message
的 Class - PrintingListener
。
我不确定为什么调用这个方法。我无法理解这个定义。有人可以解释一下这个方法的用法和调用时间吗?
根据 stomp.py documentation,PrintingListener
"just prints all interactions between the client and server." on_before_message
是 stomp.py 定义的方法之一,因此 PrintingListener
调用它。
The stomp.py API documentation 关于 on_before_message
的说法:
Called by the STOMP connection before a message is returned to the client app. Returns a tuple containing the headers and body (so that implementing listeners can pre-process the content).
Parameters:
- headers (dict) – the message headers
- body – the message body
如此处所述,on_before_message
被调用“ 以便实现侦听器可以 pre-process 内容 。”如果您不需要 pre-process 消息的内容(即 headers 或 body),那么您可以忽略此方法。
顾名思义,on_before_message
在 on_message
之前立即被调用。