<p>So i am making a Remote control panel for my RPi in go, I want to have a textbox on the site that will have a active feed from the client on the Pi, How can i do this? I don't want to have to refresh the whole page....</p>
<hr/>**评论:**<br/><br/>ptman: <pre><p>Read up on javascript, ajax, websockets.</p></pre>Wirbelwind: <pre><p>Either periodically poll the Pi, example: <a href="http://stackoverflow.com/questions/5384708/reload-a-div-with-jquery-timer" rel="nofollow">http://stackoverflow.com/questions/5384708/reload-a-div-with-jquery-timer</a> or use SSE or WebSockets.</p>
<p>SSE is easier, but is only communication from Server to client. If you want a two-way connection, set up websockets.</p></pre>goomba_gibbon: <pre><p>There are some simple examples using websockets here - <a href="https://github.com/gorilla/websocket" rel="nofollow">https://github.com/gorilla/websocket</a></p></pre>VivaceNaaris: <pre><p>Alternatively, a webworker executing an AJAX request every n interval, perhaps?</p></pre>goomba_gibbon: <pre><p>Polling like this is also an option but updates are limited by the frequency. Understanding AJAX requests is probably a better place to start than going straight to websockets.</p>
<p>The requirements aren't that clear. It depends how "active" it needs to be.</p></pre>peterhellberg: <pre><p>I'd use SSE for the event stream, and then normal POST requests for executing the commands, nothing fancy.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传