https://github.com/seajs/seajs/issues/224 看到 seajs 上出了个, 虽然实现的原理也不难... 自己做一个好的挺没底的, 可是又不是 seajs 用户... 请问各位有用过的模块能推荐么?
说的也是. 不过这么弄的话要尽量去掉任何模块的依赖... ws 也砍掉
不知道还有没有好的办法, 要不然 Ajax 轮询也郁闷了...
我想先看看个 server-send events 这个行不行...
写了命令行工具 doodle, Ubuntu 下我跑得起来了, 慢慢测试了
https://github.com/jiyinyiyong/doodle
http://jiyinyiyong.github.com/blog/posts/120821-doodle-刷新页面.html
忘了结帖... 写好了 https://github.com/jiyinyiyong/doodle
基于 websocket, 低版本 IE 不支持, 在我的 Ubuntu 上运行还是良好的.
刚开始尝试的记录写在这里:
http://jiyinyiyong.github.com/blog/posts/120821-doodle-刷新页面.html
用法
sudo npm install -g doodle
命令行运行开始之后, 在 8071 打开一个 websocket 端口, 8072 一个 HTTP 端口,
浏览器段加入下面的代码接受 websocket 的信号来进行刷新:
html
head
title doodle test
//- script(src='http://localhost:8072/doodle.js')
:coffeescript
hostname = location.hostname
ws = new WebSocket "ws://#{hostname}:8071"
ws.onmessage = (message) ->
if message.data is 'reload'
do location.reload
body waiting
或者直接 <script> 引入 8072 端口的 /doodle.js 脚本, 就是上面的代码.
具体的 .html 文件可以看这里:
https://github.com/jiyinyiyong/doodle/tree/master/example