论坛首页 Web前端技术论坛

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

浏览 13174 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (13)
作者 正文
   发表时间:2011-06-19  

聊天室v0.9 该版本实现了简单的聊天功能,是一个pushlet的入门例子,仅供学习之用.

如果大家完善了某些功能请发贴共享一下!谢谢! !

 

使用了:pushlet 2.0.4 + Extjs4.0.2

服务器:tomcat6.0+

 

 

效果图:

 


 


 


 

 

  • 大小: 151.9 KB
  • 大小: 187.5 KB
  • 大小: 196.9 KB
   发表时间:2011-06-20  
lz威武。。谢谢了,刚好要做这个~
0 请登录后投票
   发表时间:2011-06-21  
相应的Jar包你没有提交的吧
0 请登录后投票
   发表时间:2011-06-21  
w3cweb 写道
相应的Jar包你没有提交的吧


我用的是pushlet的源码,不是jar包.
0 请登录后投票
   发表时间:2011-06-21  
楼主V5。下来看看。
0 请登录后投票
   发表时间:2011-06-21   最后修改:2011-06-21

偶前几也弄了一下,想用Pushlet做一个向客户端广播消息的功能:比如管理员发布一个消息后,所有建立了长连接的客户端将实时的收到这个消息。但做的时候碰到个问题如下.不知楼主是否碰到,望赐教

 

hi,jounne

i previewed that your discussion on chrome'issue about pushlets comet technology.
At last you say "Content-Type: application/octet-stream" will work。But it does not work for me.
So , i write to u for help.

my problems as follows:

I use pushlets created a long connection to request a method to get some infos via this long connection
without refresh my page. it works very well on firefox but what a big pity on chrome.

The detail is that, after i send the request via firefox client, i monitored the long connection is effective with firebug,
i received data bit by bit from server; but this state disappear into thin air when i use chrome client,
the chrome can create connection too, but the connection is not long connection, i monitored that the request was growing.
it is one request one response。

my code as follows:

JavaCode
static public class SystemStatusEventPullSource extends EventPullSource {
Runtime runtime = Runtime.getRuntime();

public long getSleepTime() {
return 1000;
}

public Event pullEvent() {
Event event = Event.createDataEvent("/system/jvm");
event.setField("已申请到的内存", "" + runtime.totalMemory());
event.setField("空闲内存", "" + runtime.freeMemory());
event.setField("可申请分配的内存", "" + runtime.maxMemory());
int activeCount = Thread.activeCount();
event.setField("threads", "" + activeCount);
return event;
}
}


ClientCode
<script type="text/javascript">
// Initialization
function init() {
p_join_listen('/system/jvm');
}

// Event Callback: display all events
function onEvent(event) {
document.eventDisplay.EVENT.value = event.toString();
}
</script>

Finally, i modified the pushlets source code follow your workaround.
BrowserAdapter.java
Line 42
servletRsp.setContentType("text/html;charset=UTF-8");
TO
servletRsp.setContentType("application/octet-stream");

that is all.

Best wishes!

XiongChun from KunMing China.


另外一个问题是我在pullEvent()方法中如何获取到登录用户的回话信息啊?
0 请登录后投票
   发表时间:2011-06-21  
V5。看看。
1 请登录后投票
   发表时间:2011-06-22  
效果还是非常好的 ·!
0 请登录后投票
   发表时间:2011-06-22   最后修改:2011-06-22
做长连接可以试试NodeJS做服务器端,socket.io做客户端连接。
0 请登录后投票
   发表时间:2011-06-22  
楼主,发布代码是删掉某些东西了。不能多用户在线
0 请登录后投票
论坛首页 Web前端技术版

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