How to automatically update a Go website?

xuanbao · · 397 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<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&#39;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&#39;t that clear. It depends how &#34;active&#34; it needs to be.</p></pre>peterhellberg: <pre><p>I&#39;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

397 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传