NodeMCU HTTP 是否支持多个同时回调函数?
Does NodeMCU HTTP support multiple simultaneous callback functions?
NodeMCU是否支持同时存在(即注册)的多个HTTP回调函数?
场景:两个定时器,独立运行,调用两个不同的函数。每个函数都发出自己的 HTTP 请求并注册一个回调函数。
如果在调用第一个HTTP请求回调函数之前发出第二个HTTP请求(即在收到服务器对第一个HTTP请求的响应之前触发第二个HTTP请求),则将同时注册两个HTTP回调函数时间。这是 valid/supported,还是我们需要设计我们的应用程序以确保在第一个请求完成之前不会发出第二个 HTTP 请求?
引用docs:
Note that it is not possible to execute concurrent HTTP requests using
this module. Starting a new request before the previous has completed
will result in undefined behavior.
所以,你的问题的答案是否定的。
NodeMCU是否支持同时存在(即注册)的多个HTTP回调函数?
场景:两个定时器,独立运行,调用两个不同的函数。每个函数都发出自己的 HTTP 请求并注册一个回调函数。
如果在调用第一个HTTP请求回调函数之前发出第二个HTTP请求(即在收到服务器对第一个HTTP请求的响应之前触发第二个HTTP请求),则将同时注册两个HTTP回调函数时间。这是 valid/supported,还是我们需要设计我们的应用程序以确保在第一个请求完成之前不会发出第二个 HTTP 请求?
引用docs:
Note that it is not possible to execute concurrent HTTP requests using this module. Starting a new request before the previous has completed will result in undefined behavior.
所以,你的问题的答案是否定的。