http://svn.xantus.org/shortbus/trunk/bayeux/bayeux.html
要了解DOJO的COMETD的实现,最好先了解一下这个协议
http://cometd.com/
http://dojotoolkit.org/
http://jetty.mortbay.org/jetty-6/
http://cometdproject.dojotoolkit.org/
Cometd
The Scalable Comet Framework.
Cometd is a scalable HTTP-based event routing bus that uses a push technology pattern known as Comet. The term 'Comet' was coined by Alex Russell in his post 'Comet: Low Latency Data for the Browser'. The letter d is for 'Daemon', as described by Answers.com, Daemon is a program or process that sits idly in the background until it is invoked to perform its task. Cometd consists of a protocol spec called Bayeux, JavaScript libraries (dojo toolkit), and an event server.
Cometd = Comet + Daemon = dojo (js) + Bayeux(协议) + Jetty(事件驱动的WEB服务器)
Messages
Submitted by gregwilkins on Thu, 06/05/2008 - 02:53.
Specification vs Instantiation vs Transport
Bayeux messages:
- are specified in JSON.
- should be instantiated in the natural object representation of the language used for the client/server
- may be transported via any appropriate serialization that the specific transport supports. This may be a JSON String, an XML document or some other serialization.
A simple bayuex message could be specified as:
{channel:"/some/channel",data:[1,2,3]}
This message has a natural instantiation in javascript. The message could be transported as a wire format that uses the JSON as described above, or the instantiated javascript objects could be serialized to XML if some transported wished. If delivered to a java bayeux implementation, then the message would be instantiated as a java.util.Map<String,Object>
instance that contained java.lang.String
keys and values of type java.lang.String
and java.util.Array<Object>
.
Reserved Fields
All fields in the top level of a json message are reserved for the use of the protocol. The following fields are the most important defined fields:
channel All messages MUST have a channel field with a string value that identifies the handler for the message. clientId A message MAY have a clientId field with a string value that with identity of the client. ClientIDs are only unique within a single non-cluster Bayeux server and are only valid for the duration of the Bayeux connected state. They should be considered roughly equivalent to a HTTP session ID and treated the same with regards to security and longevity. id Any message may contain an id field with a string value that identifies the message. The id is generated by the creator of the message and it's uniqueness or otherwise is application specific. data The message payload. An arbitrary object advice Transport specific parameters. ext Extension space successful Indicates the success of a protocol operation. Used in a response message error Error code and message
Channel
Submitted by gregwilkins on Thu, 06/05/2008 - 02:52.
Channels look like URIs: /foo/bar
Channels starting with /meta/ are reserved for the use of the protocol (eg /meta/handshake)
Channels are by default broadcast publish subscribe, so that all subscribers will see all messages published to the channel on the server.
Messages may be privately delivered to a specific client + channel combination and bypass any default routing.
Channels starting with /service are server only publish/subscribe. Messages published to /service channels will only be delivered to server side clients.
Messages may still be explicitly delivered to a client on a /service channel
1.4.6. Two connection operation
In order to achieve bi-directional communications, a Bayeux client will use two HTTP connections to a Bayeux server so that both server to client and client to server messaging may occur asynchronously:
BC ---------- U ---------- P ------------ O ---------- BS
| ---M0---> | | | |
| | ------ req0(M0) --------> | |
| | | | ----M0---> |
~ ~ ~ ~ ~ wait
| --M1(E1)-> | | | |
| | ----- req1(M1(E1))------> | |
| | | | --M1(E1)-> |
| | | | <---M2---- |
| | <---- resp1(M2)---------- | |
| <---M2--- | | | |
~ ~ ~ ~ ~ wait
| | | | <-M3(E2)-- |
| | <-----resp2(M3(E2))------ | |
| <-M3(E2)-- | | | |
| ---M4---> | | | |
| | ------req3(M4)----------> | |
| | | | ----M4---> |
~ ~ ~ ~ ~ wait
HTTP requests req0 and req1 are sent on different TCP/IP connections, so that the response to req1 may be sent before the response to req0. Implementations MUST control HTTP pipelining so that req1 does not get queued behind req0 and thus enforce an ordering of responses.
...to be continued.
分享到:
相关推荐
cometd bayeux jar 类库
6. 关闭CometD:在应用关闭时,记得正确地关闭CometD实例,释放资源。 通过深入理解和熟练运用`cometd-bayeux-6.1.10.jar`,开发者可以构建出高效、稳定的实时应用,提升用户的交互体验。同时,CometD社区活跃,...
基于库 特征: 无需编写一行 Javascript 即可创建推送应用程序 完全可配置 使用设置传入消息的格式 消息(使用字符串或自定义对象) 建立在坚如磐石的库之上 支持 抽象(在之上) 消息到达时客户端更新策略的选择...
CometD 计划 欢迎使用该项目,这是一个用于 Web 的可扩展彗星(服务器推送)实现。 CometD 版本 7.0.x ⇒ Java 11 - Jetty 11.0.x - jakarta.servlet.* 6.0.x ⇒ Java 11 - 码头 10.0.x - javax.servlet.* 5.0.x ⇒ ...
3. **Bayeux Protocol**: Bayeux协议是CometD的核心,它定义了一种JSON格式的消息交换机制,用于在服务器和客户端之间进行长连接通信。"cometd-bayeux-6.1.9.jar"包含了这个协议的实现,使得Jetty可以通过这个库支持...
- **客户端半对象**:在远程客户端一侧,通过 JavaScript 的 `org.cometd.Cometd` 对象或 Java 中的 `org.cometd.bayeux.client.ClientSession` 类表示。 - **创建会话**:客户端通过创建客户端会话来与服务器建立 ...
CometD是一个开源的、基于Bayeux协议的JavaScript库,用于实现服务器推送技术(Server-Sent Events)。它使得Web应用程序能够实现实时通信,即服务器可以主动向客户端推送数据,而无需客户端频繁地发送请求。这个...
CometD使用Bayeux协议进行客户端和服务端之间的通信,Bayeux协议的消息格式是JSON。Bayeux协议还定义了元数据频道、服务频道和广播频道三种不同的频道类型。 元数据频道是由Bayeux协议自动创建和维护的,应用程序不...
CometD是一个开源的、基于Java的WebSocket和Bayeux协议的实时Web应用程序框架。它提供了服务器推送技术,使得服务器可以主动向客户端发送数据,而不仅仅是响应客户端的请求。CometD的核心理念是通过长连接来实现双向...
cometd-bayeux-6.1.9 jetty-6.1.9 jetty-util-6.1.9 servlet-api-2.5-6.1.9 全网搜索dojox.cometd实现WEBQQ,没有可以运行的源码包项目,搞了五天,分享给大家,真实可用,jar包就找了好久,花了5分,搞了5天5分。共...
CometD是一个开源的、基于Bayeux协议的实时通信框架,主要应用于构建WebSocket和Ajax的长连接,实现服务器向客户端的实时数据推送。在Java领域,CometD被广泛用于构建类似QQ聊天和微信这样的实时通讯应用。下面将...
CometD是一个开源的、基于Bayeux协议的双向通信框架,它允许Web服务器向客户端实时推送数据,而无需客户端不断发起请求。这种技术在现代Web应用中非常常见,尤其适用于实时聊天、股票更新、在线游戏等场景。下面将...
CometD是一个开源的、基于WebSocket的实时通信框架,它实现了Bayeux协议,使得Web应用可以实现双向通信,即服务器可以主动向客户端推送数据,而不仅仅是响应客户端的请求。在"cometd-5.0.x.zip"这个压缩包中,包含了...
CometD是一个开源的、基于Java的WebSocket和Bayeux协议的实时Web应用程序框架,它使得服务器能够与浏览器或其他客户端进行双向通信,实现高效的推送服务。这个“CometD2.x官方帮助手册”是该技术的离线版文档,包含...
CometD是一个基于Bayeux协议的开源 comet(也称为长轮询)框架,它提供了一个高效的、可扩展的、跨平台的实时通信解决方案。在Web开发中,实时通信是实现如聊天、股票更新、协作编辑等应用的关键技术。CometD支持...
CometD是一个基于Bayeux协议的开源JavaScript库,它实现了服务器推送技术,允许服务器主动向客户端发送数据,而不仅仅是响应客户端的请求。这个“cometd实例demo”提供了使用CometD的一个实际示例,可以帮助开发者...
如何使用它下载特定版本的CometD Dojo绑定,浏览 在您选择的目录下的目录结构(已经有Dojo(和其他库))中解压缩CometD Dojo绑定,例如目录cometd-dojo/ : dojo/dijit/cometd-dojo/ cometd/ org/ cometd.js 现在,...
CometD是一个基于Bayeux协议的开源框架,专门用于实现服务器到客户端的实时双向通信。这个框架在Web应用中非常有用,特别是对于需要实时更新数据的场景,比如聊天、股票报价、在线游戏等。CometD的核心理念是提供一...
CometD是一个开源的WebSocket和AJAX双向通信框架,它实现了Bayeux协议,允许服务器主动向客户端推送数据,实现低延迟的实时通信。Spring框架则为这个项目提供了强大的依赖注入和面向切面编程能力,使得服务端组件的...
CometD是一个开源的、基于Java的实时Web通信框架,它实现了Bayeux协议,允许服务器与客户端之间进行双向通信,实现高效的推送服务。在Web应用中,CometD广泛用于构建实时聊天、股票更新、在线游戏等需要即时数据交换...