标签:style blog http java color 文件
pushlet点对点单播,在网上看 ,大家都是将包修改然后替换lib中class,其实不用不这么麻烦,java可以继承嘛,继承原来的类重写里面的方法就行,不必编译出来替换class,这样不方便修改
新建一个类,继承nl.justobjects.pushlet.core.SessionManager类,重写里面的createSession方法即可
package com.pushlet.serveToClient;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import nl.justobjects.pushlet.core.Event;
import nl.justobjects.pushlet.core.Session;
import nl.justobjects.pushlet.core.SessionManager;
import nl.justobjects.pushlet.util.PushletException;
public class MySessionManager extends SessionManager {
@Override
public Session createSession(Event anEvent) throws PushletException {
// TODO Auto-generated method stub
HttpSession s = ServletActionContext.getRequest().getSession();
String userid=s.getAttribute("userid")+"";
return Session.create(userid);
}
}
然后修改配置pushlet.properties这个配置文件
然后调用方法推送
Event event =Event.createDataEvent("/mutiSend");
event.setField("msg", URLEncoder.encode(remindContent+"<br/>推送时间:"+new Date().toLocaleString(),"UTF-8"));
Dispatcher.getInstance().unicast(event, "muyunfei");
pushlet服务端推送——点对点单播(不用修改lib包),布布扣,bubuko.com
标签:style blog http java color 文件
原文地址:http://blog.csdn.net/myfmyfmyfmyf/article/details/36656931