1.1 Comt4j1.1.1 introduction Comet4J (Comet for Java) is a server push framework purely based on AJAX (XMLHTTPRequest). messages are transmitted in JSON format, three working modes are available: Long polling, long connection, and automatic selection. Feature: pushes message broadcasts. · Push targeted messages. · Various events that can be handled before connection, online, offline, offline, and message sending are provided. · Message caching mechanism ensures that messages are not lost in long polling mode. · The client is normally offline, and the server can immediately perceive it. · The client stops working abnormally. The server can regularly check and detect exceptions. · By registering a channel application, developers can expand the framework functions to implement their own applications. Framework features: independent and small, not dependent on third-party packages. · Tightly integrated with applications without independent applications or servers. · The Session-independent Connection Mechanism provides developers with maximum functional controllability. · Event-oriented programming. Both the client and server are event-driven development models, providing a sound scalability mechanism. · All performance parameters can be configured. · Supports multiple mainstream browsers and Air application environments. Server support: Tomcat 6 and tomcat 7 browsers that support XMLHTTPRequest objects support long polling mode, but not necessarily long connections. Browser/platform version long polling persistent connection Internet assumer6, 9 √ XFireFox3.0 + (unknown version) √ Chrome7.0 + (unknown Version) √ Safari5 + (unknown version) √ Opera11.10 + (unknown version) √ XAir1.5 + (unknown version) √ IOS (Iphone/Ipad) 3.1 + (unknown version) √ Android not tested unknown BlackBerry not tested unknown comparison: Pushlet instance parsing and Servlet3.0 server push technology 1.1.2 server package org. comet4j. demo. helloworld; import javax. servlet. servletContextEvent; import javax. servlet. servletContextListener; import org. comet4j. core. cometContext; import org. comet4j. core. cometEngine; public class HelloWorld implements ServletContextListener {private static final String CHANNEL = "hello"; public void contextInitialized (ServletContextEvent arg0) {CometContext cc = CometContext. getInstance (); cc. registChannel (CHANNEL); Thread helloAppModule = new Thread (new HelloAppModule (), "Sender App Module"); helloAppModule. setDaemon (true); helloAppModule. start ();} class HelloAppModule implements Runnable {public void run () {while (true) {try {Thread. sleep (1000);} catch (Exception ex) {ex. printStackTrace ();} CometEngine engine = CometContext. getInstance (). getEngine (); // push the remaining memory size of the current server. sendToAll (CHANNEL, Runtime. getRuntime (). freeMemory ()/1024) ;}} public void contextDestroyed (ServletContextEvent arg0) {}} 1.1.3 client