1.2.1. Direct Publishing (local)
Your application may directly publish Events by using
/src/nl/justobjects/pushlet/core/Dispatcher.getInstance().java
.
Since Dispatcher
is (currently) a Singleton, sending the Event is a matter of
callingDispatcher.getInstance().multicast()/unicast()/broadcast()
.
The other two methods (EventSource and Pushlet protocol) will eventually call
Dispatcher.getInstance().multicast()/unicast()/broadcast()
.
Note that in order to call
Dispatcher.getInstance().multicast()/unicast()/broadcast()
,
your class needs to be
in the same classloader as the Dispatcher.getInstance(). This may be an issue
when for example your sender is
in another web application. You may use the Pushlet protocol
in that case or put pushlet.jar on the system
CLASSPATH. In Tomcat you can also make pushlet.jar a shared library.
直接用Dispatcher的方法发布,可以向所有人广播,发布给订阅者,指定sessionid发布
1.2.2. Using EventSource
An EventSource is an object that is managed (activated/passivated)
by the Pushlet framework.
Developing your own EventSource involves
creating a class that implements
nl.justobjects.pushlet.core.EventSource
(when your EventSource
pushes Events to the framework)
or that extends
nl.justobjects.pushlet.core.EventPullSource
(when the framework should
pull your EventSource at dedicated intervals) and adding
your EventSource to a properties file aptly namedsources.properties
.
See
/webapps/pushlet/WEB-INF/classes/sources.properties
for an example. This file
specifies which EventSource objects need
to be created and managed. Note: since v2.0.3
sources.properties
can also be placed
under WEB-INF.
See
/src/nl/justobjects/pushlet/core/EventSourceManager.java
how this is done. See examples
in
/src/nl/justobjects/pushlet/test/TestEventPullSources
where several example
sources are bundled.
During initialization the
EventSourceManager
will look for the
file
sources.properties
in the CLASSPATH. Usually this file
will be put under WEB-INF/classes.
一个自己写的事件源类,需要配置在sources.properties
,要继承EventPullSource
或实现EventSource
1.2.3. Using the Pushlet protocol
The Chat and WebPresentation examples use the remote
publication of events
through the Pushlet (control) protocol. In a webapp the Pushlet JS API provides
a p_publish() method through which your app may send events.
The
/src/nl/justobjects/pushlet/test/PushletPingApplication.java
provides a complete example illustrating sending and receiving Events and
using/src/nl/justobjects/pushlet/client/PushletClient.java
.
DHTML clients may use the JavaScript pushlet library.
使用pushlet 协议 收发交互 , 可以跨服务器
分享到:
相关推荐
服务器推 pushlet 服务器推 pushlet 服务器推 pushlet 服务器推 pushlet
pushlet开发与应用
pushlet白皮书pushlet白皮书pushlet白皮书pushlet白皮书pushlet白皮书
pushlet配置应用实例,看了之后就能简单应用pushlet实时推送数据
pushlet例子,Pushlet 是一个开源的 Comet 框架,Pushlet 使用了观察者模式:客户端发送请求,订阅感兴趣的事件;服务器端为每个客户端分配一个会话 ID 作为标记,事件源会把新产生的事件以多播的方式发送到订阅者的...
Pushlet简单示例测试
个人制作整理的pushlet白皮书中文参考文档。 目录: 1.介绍(Introduction) 3 2.动机(Motivation) 4 3.通知解决(Notification Solutions) 5 3.1轮询(Polling) 6 3.2服务器端回调(Server-side callbacks) 6 3.3 ...
Pushlet是一种comet实现:在Servlet机制下,数据从server端的Java对象直接推送(push)到(动态)HTML页面,而无需任何Java applet或者插件的帮助。它使server端可以周期性地更新client的web页面,这与传统的request...
pushlet 所需夹包 和配置文件 ajax-pushlet-client.js pushlet-sessionid.jar sources.properties pushlet.properties
pushlet文档和项目
实现通过pushlet,进行点对点聊天功能。 包括: 在线用户上线的通知 离线的通知 来新消息时的通知 前台使用Ext ,后台使用pushlet /pushlet/WebRoot/index.jsp 页面主要包含几个部分。 Ext.PUSHLET_URL='...
对comet实现中的pushlet框架进行说明,可以参照该说明进行框架使用
容易上手的简单pushlet例子,供大家学习,代码不错,值得下载。
pushlet 和comet 资料介绍 介绍如何从服器端push subscrite 给浏览器
demo中有定时推送获取和按需求推送获取的方式,改写了一部分原始pushlet的js
pushlet 实例,简单实例,带jar包,可直接运行
pushlet简单demo,导入即可运行 Java 推送 长连接 轮询 pushlet comet4j
Pushlet的Ajax-pushlet-client.js分析 服务器推技术前台js分析 希望能帮到大家
实现通过pushlet,进行点对点聊天功能。 包括: 在线用户上线的通知 离线的通知 来新消息时的通知 前台使用Ext ,后台使用pushlet /pushlet/WebRoot/index.jsp 页面主要包含几个部分。 Ext.PUSHLET_URL='...