`
sillycat
  • 浏览: 2539981 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Comet-Jetty(4)Read the Source Codes and Refactor the Project

 
阅读更多
Comet-Jetty(4)Read the Source Codes and Refactor the Project

1. Find resources
Install the source to my repository, then it is easy for me to read the source codes.
>mvn -DskipTests=true source:jar install

2. Create new Project easytalker/easycometd
easycometd will handle the page messages.
easytalker will handle the offline messages.
easyandroidspeaker will handle the android client in the feature.

The client Class will be as follow to support the private talk message:
public void go() throws InterruptedException {
String defaultURL = "http://localhost:8080/easycometd/cometd";
String url = defaultURL;

client = new BayeuxClient(url, LongPollingTransport.create(null));
client.getChannel(Channel.META_HANDSHAKE).addListener(
new InitializerListener(nickname, client, chatListener,
membersListener));
client.getChannel(Channel.META_CONNECT).addListener(
new ConnectionListener(nickname, client));

client.handshake();

boolean success = client.waitFor(2000, BayeuxClient.State.CONNECTED);
if (!success) {
System.err.printf("Could not handshake with server at %s%n", url);
return;
}

String text = "hello,where is the book";

Map<String, Object> data = new HashMap<String, Object>();
data.put("user", nickname);
data.put("chat", text);
client.getChannel("/chat/demo").publish(data);

Map<String, Object> pdata = new HashMap<String, Object>();
text = "hello,where is the money";
pdata.put("chat", text);
pdata.put("room", "/chat/demo");
pdata.put("user", "karl");
pdata.put("peer", "sillycat");
client.getChannel("/service/privatechat").publish(pdata);

for (int i = 0; i < 10; i++) {
Thread.sleep(5000);
}

data = new HashMap<String, Object>();
data.put("user", nickname);
data.put("membership", "leave");
data.put("chat", nickname + " has left");
client.getChannel("/chat/demo").publish(data);

client.getChannel("/service/privatechat").release();
client.getChannel("/chat/demo").release();
client.disconnect(3000);
}

3. Error Message Tips
Error Message
802 [HttpClient-13] INFO org.cometd.client.BayeuxClient.1188088890 - Messages failed [{id=7, connectionType=long-polling, channel=/meta/connect, clientId=33uitvf0nskcyrayr07o0zvdt}]
java.net.ProtocolException: Unexpected response 500: TransportExchange@2ae522a0=POST//localhost:8080/easycometd/cometd/connect#CONTENT(0ms)->COMPLETED(0ms)sent=23ms
at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:1161)
at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.java:324)
at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:1153)
at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:300)

SEVERE: Servlet.service() for servlet [cometd] in context with path [/easycometd] threw exception
java.lang.IllegalStateException: Not supported.
at org.apache.catalina.connector.Request.startAsync(Request.java:1664)
at org.apache.catalina.connector.Request.startAsync(Request.java:1657)
at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1023)
at org.eclipse.jetty.continuation.Servlet3Continuation.suspend(Servlet3Continuation.java:171)
at org.cometd.server.transport.LongPollingTransport.handle(LongPollingTransport.java:288)
at org.cometd.server.CometdServlet.service(CometdServlet.java:181)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:212)
at org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:179)

solution
There is solution to deal with tomcat7. Maybe only some configuration changes, but I just use tomcat6.x to run my project, it is ok now.


references:


分享到:
评论

相关推荐

    gwt-comet-jar包+实例+source.jar包,

    里面东西很多,都是关于GWT-COMET的内容,实现gwt的服务器推技术,包括gwt-comet-examples-...gwt-comet-1.2.3.jar:jar包,gwt-example:聊天实例源代码(.java的),gwt-event-source-1.0.0.jar:comet事件源jar包。

    comet-iframe.rar

    在"comet-iframe.rar"这个压缩包中,可能包含了关于如何将PHPComet集成到IFrame中的示例代码、配置文件或者教程文档。这些资源可以帮助开发者理解如何创建一个可以实时更新的IFrame,以及如何配置PHPComet服务器来...

    comet-ajax

    comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天

    comet-atomic-2020

    (Comet-)ATOMIC 2020:关于符号和神经常识知识图 纸 耶拿·黄(Jena D. Hwang),钱德拉(Chandra Bhagavatula),罗南·勒布拉斯(Ronan Le Bras),杰夫·达(Jeff Da),坂口圭介(Keisuke Sakaguchi),安托万...

    Python库 | unbabel-comet-0.0.1.tar.gz

    在本文中,我们将深入探讨名为"unbabel-comet-0.0.1"的Python库,该库被封装在一个名为"unbabel-comet-0.0.1.tar.gz"的压缩文件中。 "unbabel-comet-0.0.1.tar.gz"是一个典型的源代码打包文件,它采用了tar格式用于...

    atmosphere-flick-comet-0.2-m1-sources.jar

    atmosphere-flick-comet-0.2-m1-sources.jar

    atmosphere-flick-comet-0.3.1-sources.jar

    atmosphere-flick-comet-0.3.1-sources.jar

    atmosphere-flick-comet-0.5.1-sources.jar

    atmosphere-flick-comet-0.5.1-sources.jar

    atmosphere-flick-comet-0.4-sources.jar

    atmosphere-flick-comet-0.4-sources.jar

    atmosphere-flick-comet-0.3-sources.jar

    atmosphere-flick-comet-0.3-sources.jar

    atmosphere-flick-comet-0.2-sources.jar

    atmosphere-flick-comet-0.2-sources.jar

    atmosphere-flick-comet-0.1-sources.jar

    atmosphere-flick-comet-0.1-sources.jar

    comet4j 所需js以及comet4j-tomcat6.jar、comet4j-tomcat7.jar包

    综上所述,这个压缩包包含的`comet4j.js`、`comet4j-tomcat6.jar`和`comet4j-tomcat7.jar`是实现基于Java的Comet4j实时通信框架的关键组件。它们分别负责客户端的JavaScript交互、在Tomcat服务器上的集成和支持,为...

    科密点钞机升级操作指引教程

    科密点钞机升级操作指引教程,升级识别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扩展

    Comet-For-MLFlow扩展 Comet-For-MLFlow扩展是一个CLI,可将MLFlow实验运行映射到Comet实验。 此扩展程序使您可以在Comet.ml UI中查看现有实验,该UI提供了对实验结果的经过身份验证的访问权限,大大提高了大批量...

    comet-jquery

    【comet-jquery】是一种基于jQuery的实时通信技术,它利用了Comet技术来实现服务器向客户端推送数据的功能。在Web开发中,传统的HTTP协议是请求-响应模式,即客户端发起请求,服务器返回数据,而Comet技术打破了这种...

    科密票据打印机官方驱动程序 COMET-CM-30 官方版(32位/64位)

    科密票据打印机官方驱动程序 COMET-CM-30是CM-30票据打印机的官方驱动,使用这款驱动能完美驱程COMET-CM-30的票据打印机,有需要的用户可以下载驱动程序安装。小编已经把win32位和win64位的驱动都打包在压缩包里,请...

    科密票据打印机官方驱动程序 COMET-CK-300K 官方版(32位/64位)

    科密票据打印机官方驱动程序 COMET-CK-300K是CK-300K打印机的专用驱动程序,能完美驱程COMET-CK-300K的票据打印机,有需要的用户可以下载驱动程序安装。小编提供了32位和64位的驱动,请用户根据自身系统选择对应的...

    Comet Reverse Ajax

    6.1.11) and replace the Jetty jar files in your grails installation. The files that I modified were: - jetty-6.1.x.jar - jetty-naming-6.1.x.jar - jetty-plus-6.1.x.jar - jetty-util-6.1.x.jar 3. ...

    Python库 | comet_ml-2.0.12.tar.gz

    在实际使用Comet_ml时,首先需要通过pip安装:`pip install comet-ml`。然后,在项目开始时,引入comet_ml库并初始化实验,例如:`from comet_ml import Experiment; experiment = Experiment(api_key="YOUR_API_KEY...

Global site tag (gtag.js) - Google Analytics