- 浏览: 2552656 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Comet-Jetty(1)CometD Design and Go through document
First of all, I tried jetty6.1.3, chat demo. I have demoed that before. But I do not think it is a good way to solve my problem on hand.
So I try to download the latest cometd2.x project and read the document.
1. Prepare the project
>git clone https://github.com/cometd/cometd.git
build the whole project at the root path
>mvn clean install
I think there are many parts useful to me.
1.1 full chat applications with jquery
1.2 examples of extensions such as message acknowledgement, reload, timesync and timestamp.
1.3 an example of how to echo private message to a particular client only
running the demos with maven.
>cd cometd-demo
>mvn jetty:deploy-war
Then I visit the URL http://localhost:8080 to take a look at the demo.
2. Primer
2.2.1 Setting Up the Project in Maven Way
CometD libraries using maven uses the maven archetype, which create the skeleton of the project.
>cd D:\work\cometd
>mvn archetype:generate -DarchetypeCatalog=http://cometd.org
I choose 5 to have a try here:
5: http://cometd.org -> org.cometd.archetypes:cometd-archetype-spring-jquery-jetty7 (2.4.3 - CometD
archetype for creating a server-side event-driven web application)
Confirm properties configuration:
groupId: com.sillycat
artifactId: easycometd
version: 1.0
package: com.sillycat.easycometd
cometdVersion: 2.4.3
jettyVersion: 7.6.4.v20120524
slf4jVersion: 1.6.4
springVersion: 3.1.1.RELEASE
I copy the directory to my working directory d:/work/easy/easycometd.
>cd d:/work/easy/easycometd
>mvn eclipse:eclipse
I can import this project to eclipse. I delete the parent configuration in pom
<parent>
<artifactId>cometd-project</artifactId>
<groupId>org.cometd</groupId>
<version>2.5.0-SNAPSHOT</version>
</parent>
And take a look at the demo.
>mvn install jetty:run
We can visit this URL http://localhost:8080/easycometd/, but there is not much information. I will try more on this demo after I read documents.
3. Concept & Architecture
The CometD Project uses the Bayeux protocol to exchange the information between the client and the server.
The unit of information exchanged is a Bayeux message formatted in JSON.
All messages the client and server exchange have a channel field. The channel field provides the characterization of messages in classes. The channel is a central concept in CometD: publishers publish messages to channels, and subscribers subscribe to channels to receive messages. This is strongly reflected in the CometD APIs.
3.1.1.Channel Definitions
A channel that starts with /meta/ is a meta channel, a channel that starts with /service/ is a service channel, and all other channels are broadcast channels.
3.1.1.1 Meta Channels
CometD implementation creates meta channels, application can not. Provide information about protocol.
3.1.1.2. Service Channels
Applications create service channels for request/response style of communication.
3.1.1.3. Broadcast Channels
Applications also create broadcast channels. One sender wants to broadcast information to multiple recipients.
3.1.1.4. Use of Wildcards in Channels
3.3.1 Sessions
Client Sessions
org.cometd.bayeux.client.ClientSession
org.cometd.bayeux.client.BayeuxClient
Server Sessions
org.cometd.bayeux.server.ServerSession
they are the counterpart of client sessions. When a client creates a client session, it is not initially associated with a correspondent server session. Only when a client session establishes the Bayeux communication with the server does the server create its correspondent server session, as well as the link between the two half-objects.
Local Sessions
org.cometd.bayeux.server.LocalSession
Local sessions can be thought of as clients living in the server. They do not represent a remote client, but instead a server-side client.
3.3.4 Message Processing
3.3.5. Application Interaction
4.1. Configuring and Initializing
in application.js, we can see the configuring:
var cometURL = location.protocol + "//" + location.host + config.contextPath + "/cometd";
cometd.configure({
url: cometURL,
logLevel: 'debug'
});
After we call cometd.handshake(); The client will connect to the server.
The call to handshake() (or to init()) initiates the Bayeux communication with the Bayeux server.
4.2. Handshaking
The client and the server negotiate the type of transport to use.
Once the transport negotiates successfully, the server informs the client with the detailed timings of the requests.
4.3.4. Subscribers and Listeners
addListener() ----> removeListener()
subscribe() ----> unsubscribe()
addListener()
Must be used to listen to meta channel messages
May be used to listen to service channel messages
Should not be used to listen broadcast channel messages(use subscribe() instead)
Is synchronous
Does not involve any communication with the Bayeux server, and as such can be called before calling handshake().
subscribe()
Must not be used to listen to meta channels messages
May be used to listen to service channel message(but recommend, prefer to use addListener())
Should be used to listen to broadcast channel messages
Involves a communication with the Bayeux server and as such cannot be called before calling handshake().
Is asynchronous:
4.3.6. Wildcard Subscriptions
cometd.subscribe("/chatrooms/*", function(message) { ... });
4.3.7. Meta Channel List
/meta/handshake
/meta/connect
/meta/disconnect
/meta/subscribe
/meta/unsubscribe
/meta/publish
/meta/unsuccessful
4.4. Publishing
publish data onto a certain channel
cometd.publish('/mychannel',{ mydata: { foo: 'bar' } }};
It is asynchronous: it returns immediately, well before the Bayeux server has received the message.
4.7. JavaScript Transports
4.7.1. The long-polling Transport
The long-polling transport is the default transport if the browser and the server do not support WebSockets. The data is sent to the server by means of a POST request with Content-Type application/json via a plain XMLHttpRequest call.
This transport is used when the communication with the Bayeux server happens on the same domain.
Client will ask the Server for reply, if no data, Client will wait to timeout, if data, Client will receive and make another request.
4.7.2. The callback-polling Transport
The callback-polling transport is used when the communication with the Bayeux server happens on a different domain.
To overcome XMLHttpRequest restrictions, this transport uses the JSONP script injection, which injects a <script> element whose src attribute points to the Bayeux server.
4.7.3. The websocket Transport
4.7.4. Unregistering Transports
var cometd = dojox.cometd; // Dojo style
var cometd = $.cometd; // jQuery style
cometd.unregisterTransport('websocket');
The purpose is to disable certain transports that might be unreliable.
references:
http://timyang.net/category/architecture/
http://sillycat.iteye.com/blog/563598
http://wiki.eclipse.org/Jetty/
https://github.com/eclipse/jetty.project
http://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project.git
http://ftp.jaist.ac.jp/pub/eclipse/jetty/index.html
http://oss.sonatype.org/content/groups/jetty/
http://cometd.org/
http://haidii.iteye.com/blog/481004
https://github.com/cometd
https://github.com/cometd/cometd.git
http://docs.cometd.org/reference/
http://abentotoro.blog.sohu.com/203996578.html
http://yaojialing.iteye.com/blog/716094
http://docs.cometd.org/reference/#d0e117
First of all, I tried jetty6.1.3, chat demo. I have demoed that before. But I do not think it is a good way to solve my problem on hand.
So I try to download the latest cometd2.x project and read the document.
1. Prepare the project
>git clone https://github.com/cometd/cometd.git
build the whole project at the root path
>mvn clean install
I think there are many parts useful to me.
1.1 full chat applications with jquery
1.2 examples of extensions such as message acknowledgement, reload, timesync and timestamp.
1.3 an example of how to echo private message to a particular client only
running the demos with maven.
>cd cometd-demo
>mvn jetty:deploy-war
Then I visit the URL http://localhost:8080 to take a look at the demo.
2. Primer
2.2.1 Setting Up the Project in Maven Way
CometD libraries using maven uses the maven archetype, which create the skeleton of the project.
>cd D:\work\cometd
>mvn archetype:generate -DarchetypeCatalog=http://cometd.org
I choose 5 to have a try here:
5: http://cometd.org -> org.cometd.archetypes:cometd-archetype-spring-jquery-jetty7 (2.4.3 - CometD
archetype for creating a server-side event-driven web application)
Confirm properties configuration:
groupId: com.sillycat
artifactId: easycometd
version: 1.0
package: com.sillycat.easycometd
cometdVersion: 2.4.3
jettyVersion: 7.6.4.v20120524
slf4jVersion: 1.6.4
springVersion: 3.1.1.RELEASE
I copy the directory to my working directory d:/work/easy/easycometd.
>cd d:/work/easy/easycometd
>mvn eclipse:eclipse
I can import this project to eclipse. I delete the parent configuration in pom
<parent>
<artifactId>cometd-project</artifactId>
<groupId>org.cometd</groupId>
<version>2.5.0-SNAPSHOT</version>
</parent>
And take a look at the demo.
>mvn install jetty:run
We can visit this URL http://localhost:8080/easycometd/, but there is not much information. I will try more on this demo after I read documents.
3. Concept & Architecture
The CometD Project uses the Bayeux protocol to exchange the information between the client and the server.
The unit of information exchanged is a Bayeux message formatted in JSON.
All messages the client and server exchange have a channel field. The channel field provides the characterization of messages in classes. The channel is a central concept in CometD: publishers publish messages to channels, and subscribers subscribe to channels to receive messages. This is strongly reflected in the CometD APIs.
3.1.1.Channel Definitions
A channel that starts with /meta/ is a meta channel, a channel that starts with /service/ is a service channel, and all other channels are broadcast channels.
3.1.1.1 Meta Channels
CometD implementation creates meta channels, application can not. Provide information about protocol.
3.1.1.2. Service Channels
Applications create service channels for request/response style of communication.
3.1.1.3. Broadcast Channels
Applications also create broadcast channels. One sender wants to broadcast information to multiple recipients.
3.1.1.4. Use of Wildcards in Channels
3.3.1 Sessions
Client Sessions
org.cometd.bayeux.client.ClientSession
org.cometd.bayeux.client.BayeuxClient
Server Sessions
org.cometd.bayeux.server.ServerSession
they are the counterpart of client sessions. When a client creates a client session, it is not initially associated with a correspondent server session. Only when a client session establishes the Bayeux communication with the server does the server create its correspondent server session, as well as the link between the two half-objects.
Local Sessions
org.cometd.bayeux.server.LocalSession
Local sessions can be thought of as clients living in the server. They do not represent a remote client, but instead a server-side client.
3.3.4 Message Processing
3.3.5. Application Interaction
4.1. Configuring and Initializing
in application.js, we can see the configuring:
var cometURL = location.protocol + "//" + location.host + config.contextPath + "/cometd";
cometd.configure({
url: cometURL,
logLevel: 'debug'
});
After we call cometd.handshake(); The client will connect to the server.
The call to handshake() (or to init()) initiates the Bayeux communication with the Bayeux server.
4.2. Handshaking
The client and the server negotiate the type of transport to use.
Once the transport negotiates successfully, the server informs the client with the detailed timings of the requests.
4.3.4. Subscribers and Listeners
addListener() ----> removeListener()
subscribe() ----> unsubscribe()
addListener()
Must be used to listen to meta channel messages
May be used to listen to service channel messages
Should not be used to listen broadcast channel messages(use subscribe() instead)
Is synchronous
Does not involve any communication with the Bayeux server, and as such can be called before calling handshake().
subscribe()
Must not be used to listen to meta channels messages
May be used to listen to service channel message(but recommend, prefer to use addListener())
Should be used to listen to broadcast channel messages
Involves a communication with the Bayeux server and as such cannot be called before calling handshake().
Is asynchronous:
4.3.6. Wildcard Subscriptions
cometd.subscribe("/chatrooms/*", function(message) { ... });
4.3.7. Meta Channel List
/meta/handshake
/meta/connect
/meta/disconnect
/meta/subscribe
/meta/unsubscribe
/meta/publish
/meta/unsuccessful
4.4. Publishing
publish data onto a certain channel
cometd.publish('/mychannel',{ mydata: { foo: 'bar' } }};
It is asynchronous: it returns immediately, well before the Bayeux server has received the message.
4.7. JavaScript Transports
4.7.1. The long-polling Transport
The long-polling transport is the default transport if the browser and the server do not support WebSockets. The data is sent to the server by means of a POST request with Content-Type application/json via a plain XMLHttpRequest call.
This transport is used when the communication with the Bayeux server happens on the same domain.
Client will ask the Server for reply, if no data, Client will wait to timeout, if data, Client will receive and make another request.
4.7.2. The callback-polling Transport
The callback-polling transport is used when the communication with the Bayeux server happens on a different domain.
To overcome XMLHttpRequest restrictions, this transport uses the JSONP script injection, which injects a <script> element whose src attribute points to the Bayeux server.
4.7.3. The websocket Transport
4.7.4. Unregistering Transports
var cometd = dojox.cometd; // Dojo style
var cometd = $.cometd; // jQuery style
cometd.unregisterTransport('websocket');
The purpose is to disable certain transports that might be unreliable.
references:
http://timyang.net/category/architecture/
http://sillycat.iteye.com/blog/563598
http://wiki.eclipse.org/Jetty/
https://github.com/eclipse/jetty.project
http://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project.git
http://ftp.jaist.ac.jp/pub/eclipse/jetty/index.html
http://oss.sonatype.org/content/groups/jetty/
http://cometd.org/
http://haidii.iteye.com/blog/481004
https://github.com/cometd
https://github.com/cometd/cometd.git
http://docs.cometd.org/reference/
http://abentotoro.blog.sohu.com/203996578.html
http://yaojialing.iteye.com/blog/716094
http://docs.cometd.org/reference/#d0e117
发表评论
-
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 241MongoDB 2019(3)Security and Aut ... -
Memory Leak in NodeJS
2018-12-20 06:26 736Memory Leak in NodeJS I have d ... -
Remote Desktop Client
2018-12-07 13:19 1200Remote Desktop Client There is ... -
MetaBase UI Console(2)Docker on MySQL
2018-11-29 06:58 944MetaBase UI Console(2)Docker on ... -
AWS Lambda and Serverless Timeout
2018-09-20 01:20 629AWS Lambda and Serverless Timeo ... -
2018 WebSocket(1)Introduction
2018-03-20 01:22 11102018 WebSocket(1)Introduction ... -
2018 TypeScript Update(3)Introduction Basic Grammar
2018-03-08 03:08 6092018 TypeScript Update(3)Introd ... -
2018 TypeScript Update(2)Introduction Basic Grammar - Classes and Functions
2018-03-06 05:32 5592018 TypeScript Update(2)Introd ... -
2018 TypeScript Update(1)Introduction Basic Grammar - Types and Interface
2018-03-03 01:15 6052018 TypeScript Update(1)Introd ... -
Charts and Console(6)Paging
2018-03-01 00:12 586Charts and Console(6)Paging Th ... -
Vue.JS(3)Google Login
2018-02-14 04:53 1317Vue.JS(3)Google Login I just p ... -
Vue.JS(2)Monitor Water Console - ChartJS and Axios
2018-02-14 03:17 726Vue.JS(2)Monitor Water Console ... -
Vue.JS(1)Introduction and Basic Demo
2018-02-08 06:47 615Vue.JS(1)Introduction and Basic ... -
Charts and Console(5)Validation Form
2017-10-03 05:12 811Charts and Console(5)Validation ... -
Charts and Console(4)Display and Enhancement
2017-09-20 05:39 639Charts and Console(4)Display an ... -
Charts and Console(3)Auth and Login
2017-09-13 03:45 667Charts and Console(3)Auth and L ... -
Charts and Console(2)Login and Proxy
2017-08-31 05:39 879Charts and Console(2)Login and ... -
Charts and Console(1)UI Console and RESTful Client
2017-08-29 11:02 771Charts and Console(1)UI Console ... -
Blog Project(2)Express Backend API - istanbul - mocha - bunyan
2017-06-09 00:05 485Blog Project(2)Express Backend ... -
ReactJS(5)Composition vs Inheritance
2017-06-06 05:55 1117ReactJS(5)Composition vs Inheri ...
相关推荐
1. **设置PHPComet服务器**:首先,你需要在服务器上安装并配置PHPComet。这通常涉及下载源码、配置服务器环境(如Apache或Nginx)以及正确设置PHP扩展。 2. **创建IFrame HTML**:在HTML页面中插入IFrame元素,并...
(Comet-)ATOMIC 2020:关于符号和神经常识知识图 纸 耶拿·黄(Jena D. Hwang),钱德拉(Chandra Bhagavatula),罗南·勒布拉斯(Ronan Le Bras),杰夫·达(Jeff Da),坂口圭介(Keisuke Sakaguchi),安托万...
Jetty 11.0.x - jakarta.servlet.* 6.0.x ⇒ Java 11 - 码头 10.0.x - javax.servlet.* 5.0.x ⇒ Java 8 - 码头 9.4.x - javax.servlet.* CometD许可证 CometD 源代码在 Apache 2.0 许可下发布。 项目目录布局 ...
atmosphere-flick-comet-0.2-m1-sources.jar
comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天
cometd-api-0.9.20080221 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包就找了好久...
里面东西很多,都是关于GWT-COMET的内容,实现gwt的服务器推技术,包括gwt-comet-examples-1.2.3:google官网上的Test实例;gwt-comet-1.2.3.jar:jar包,gwt-example:聊天实例源代码(.java的),gwt-event-source...
"unbabel-comet"库很可能是一个与自然语言处理(NLP)相关的工具,尤其是考虑到其名称中包含的“unbabel”一词,这可能暗示了它的目标是解决多语言之间的沟通难题。"comet"可能是库中的核心模块或算法,可能与机器...
atmosphere-flick-comet-0.3.1-sources.jar
atmosphere-flick-comet-0.5.1-sources.jar
atmosphere-flick-comet-0.4-sources.jar
atmosphere-flick-comet-0.3-sources.jar
atmosphere-flick-comet-0.2-sources.jar
atmosphere-flick-comet-0.1-sources.jar
科密点钞机升级操作指引教程,升级识别2015版人民币 WJD-Comet-A30 WJD-Comet-B329 WJD-Comet-C518 WJD-Comet-D629 WJD-Comet-KM2800 WJD-Comet-KM6800
Comet-For-MLFlow扩展 Comet-For-MLFlow扩展是一个CLI,可将MLFlow实验运行映射到Comet实验。 此扩展程序使您可以在Comet.ml UI中查看现有实验,该UI提供了对实验结果的经过身份验证的访问权限,大大提高了大批量...
【comet-jquery】是一种基于jQuery的实时通信技术,它利用了Comet技术来实现服务器向客户端推送数据的功能。在Web开发中,传统的HTTP协议是请求-响应模式,即客户端发起请求,服务器返回数据,而Comet技术打破了这种...
科密票据打印机官方驱动程序 COMET-CM-30是CM-30票据打印机的官方驱动,使用这款驱动能完美驱程COMET-CM-30的票据打印机,有需要的用户可以下载驱动程序安装。小编已经把win32位和win64位的驱动都打包在压缩包里,请...
科密票据打印机官方驱动程序 COMET-CK-300K是CK-300K打印机的专用驱动程序,能完美驱程COMET-CK-300K的票据打印机,有需要的用户可以下载驱动程序安装。小编提供了32位和64位的驱动,请用户根据自身系统选择对应的...
EXAMPLE CODE FOR "Comet & Reverse Ajax" by Crane & McCarthy, FirstPress 2008 GENERAL SETUP The examples presented here use Groovy on Grails, a Java-based web technology stack. More details at ...