我使用websocket在python下的Raspberry Pi上的Robot和使用html,js和jquery的web浏览器应用程序之间进行交换。 机器人给出其角度位置来自磁力计芯片,以及webbrowser显示机器人方向。 WebBrowser按秒接收至少5条消息,然后阻止。 如何为浏览器提供一些“呼吸”以避免这种情况? 最好的祝福
I use websocket for exchange between Robot on Raspberry Pi under python, and web browser application with html, js and jquery. Robot gives its angular position coming from magnetometer chip, and webbrowser display robot direction. WebBrowser receives at least 5 messages by second, and block. How to gives some "breathes" to the browser to avoid that ? Best regards
最满意答案
要避免在浏览器中阻止行为,您需要清除事件循环中的一些空间。 有关这方面的详细解释,您可以查看此视频: https : //www.youtube.com/watch?v = 8aGhZQkoFbQ
解释会发生什么:您的浏览器被阻止处理数据,它需要“喘息空间”来直观地重新绘制已发生的变化。 如果你分解数据流并使用一些setTimeout,你可以在浏览器之间给出“呼吸”时间。 希望它能帮到你!
To avoid blocking behaviour in the browser you need to clear up some space in the event loop. For a good explanation of that, you can check out this video: https://www.youtube.com/watch?v=8aGhZQkoFbQ
To explain what happens: Your browser is blocked processing data, and it needs 'breathing space' to repaint visually the changes that have happened. If you break up the data flow and use some setTimeout's you give your browser time in between to 'breathe'. Hope it helps you!
更多推荐
发布评论