论坛首页 Web前端技术论坛

pushlet + Extjs 聊天室v0.9 (含源码)

浏览 13168 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (13)
作者 正文
   发表时间:2011-06-24  
多发几次就没反应了??
0 请登录后投票
   发表时间:2011-06-24  
webIM可关注一下webmq
0 请登录后投票
   发表时间:2011-06-24  
楼主是否可以用于项目?
0 请登录后投票
   发表时间:2011-06-24  
476461775 写道
楼主是否可以用于项目?


是一个pushlet的入门例子,仅供学习之用.想用于项目,那就要按实际改良一下
0 请登录后投票
   发表时间:2011-06-24  
eredlab 写道
偶前几也弄了一下,想用Pushlet做一个向客户端广播消息的功能:比如管理员发布一个消息后,所有建立了长连接的客户端将实时的收到这个消息。但做的时候碰到个问题如下.不知楼主是否碰到,望赐教

 

<div>hi,jounne</div>
<div><br></div>
<div>i previewed that your discussion on chrome'issue about pushlets comet
technology.  </div>
<div>At last you say "Content-Type: application/octet-stream" will work。But it
does not work for me.</div>
<div>So , i write to u for help.</div>
<div><br></div>
<div>my problems as follows:</div>
<div><br></div>
<div>I use pushlets created a long connection to request a method to get some
infos via this long connection</div>
<div>without refresh my page. it works very well on firefox but what a big pity
on chrome. </div>
<div><br></div>
<div>The detail is that, after i send the request via firefox client, i
monitored the long connection is effective with firebug, </div>
<div>i received data bit by bit from server; but this state disappear into thin
air when i use chrome client, </div>
<div>the chrome can create connection too, but the connection is not long
connection, i monitored that the request was growing.</div>
<div>it is one request one response。</div>
<div><br></div>
<div>my code as follows:</div>
<div><br></div>
<div>JavaCode</div>
<div><span style="color: #800000;">static public class SystemStatusEventPullSource
extends EventPullSource {</span></div>
<div><span style="color: #800000;">Runtime runtime = Runtime.getRuntime();</span></div>
<div><span style="color: #800000;"><br></span></div>
<div><span style="color: #800000;">public long getSleepTime() {</span></div>
<div><span style="color: #800000;">return 1000;</span></div>
<div><span style="color: #800000;">}</span></div>
<div><span style="color: #800000;"><br></span></div>
<div><span style="color: #800000;">public Event pullEvent() {</span></div>
<div><span style="color: #800000;">Event event =
Event.createDataEvent("/system/jvm");</span></div>
<div><span style="color: #800000;">event.setField("已申请到的内存", "" +
runtime.totalMemory());</span></div>
<div><span style="color: #800000;">event.setField("空闲内存", "" +
runtime.freeMemory());</span></div>
<div><span style="color: #800000;">event.setField("可申请分配的内存", "" +
runtime.maxMemory());</span></div>
<div><span style="color: #800000;">int activeCount = Thread.activeCount();</span></div>
<div><span style="color: #800000;">event.setField("threads", "" +
activeCount);</span></div>
<div><span style="color: #800000;">return event;</span></div>
<div><span style="color: #800000;">}</span></div>
<div><span style="color: #800000;">}</span></div>
<div><br></div>
<div><br></div>
<div>ClientCode</div>
<div><span style="color: #800000;">     <script
type="text/javascript"></span></div>
<div><span style="color: #800000;">       <span style="white-space: pre;"> </span>//
Initialization</span></div>
<div><span style="color: #800000;">function init() {</span></div>
<div><span style="color: #800000;">p_join_listen('/system/jvm');</span></div>
<div><span style="color: #800000;">  }</span></div>
<div><span style="color: #800000;"><br></span></div>
<div><span style="color: #800000;">// Event Callback: display all events</span></div>
<div><span style="color: #800000;">function onEvent(event) {</span></div>
<div><span style="color: #800000;">document.eventDisplay.EVENT.value =
event.toString();</span></div>
<div><span style="color: #800000;">}</span></div>
<div><span style="color: #800000;"></script></span></div>
<div><br></div>
<div>Finally, i modified the pushlets source code follow your workaround. </div>
<div>BrowserAdapter.java  </div>
<div>Line 42</div>
<div>servletRsp.setContentType("text/html;charset=UTF-8");</div>
<div>TO</div>
<div>servletRsp.setContentType("application/octet-stream");</div>
<div><br></div>
<div>that is all.</div>
<div><br></div>
<div>Best wishes!</div>
<div><br></div>
<div>XiongChun from KunMing China.</div>
<div><br></div>
<div><br></div>
<div>另外一个问题是我在<span style="color: #800000;">pullEvent()方法中如何获取到登录用户的回话信息啊?</span>
</div>


pullEvent()方法中如何获取到登录用户的回话信息啊:
这个我都没有实现,
pushlet代码不多,跟踪一下应该可以得到结果,可以去实现EventSource接口


0 请登录后投票
   发表时间:2011-06-25  
一直想做服务器推送这块  正好下来看看  谢谢分享!
0 请登录后投票
   发表时间:2011-07-05  
用Firefox看控制台 每隔大概1s发送一此请求, 是轮询服务器吗
0 请登录后投票
   发表时间:2012-05-31  
很好很强大
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics