org.atmosphere.gwt.client.impl
Class HTTPRequestCometTransport

java.lang.Object
  extended by org.atmosphere.gwt.client.impl.BaseCometTransport
      extended by org.atmosphere.gwt.client.impl.StreamingProtocolTransport
          extended by org.atmosphere.gwt.client.impl.HTTPRequestCometTransport
All Implemented Interfaces:
CometTransport

public class HTTPRequestCometTransport
extends StreamingProtocolTransport

This class uses a XmlHttpRequest and onreadystatechange events to process stream events.

The main issue with this implementation is that GWT does not generate RECEIVING events from its XMLHTTPRequest. The implementation of XMLHTTPRequest included in this package overrides that behaviour.

Another issues is that the memory required for the XMLHTTPRequest's responseText constantly grows so the server occasionally disconnects the client who then reestablishes the connection.

The protocol for this transport is a '\n' separated transport messages. The different types of transport message are identified by the first character in the line as follows:

! A connection message followed by the heartbeat duration as an integer

? A clean server disconnection message

# A heartbeat message

* A padding message to cause the browser to start processing the stream

] A string message that needs unescaping

| A string message that does not need unescaping

[ A GWT serialized object

R, r or f A GWT deRPC object

string messages are escaped for '\\' and '\n' characters as '\n' is the message separator.

GWT serialized object messages are escaped by GWT so do not need to be escaped by the transport

Author:
Richard Zschech

Nested Class Summary
 
Nested classes/interfaces inherited from class org.atmosphere.gwt.client.impl.BaseCometTransport
BaseCometTransport.RPCServerTransport
 
Field Summary
 
Fields inherited from class org.atmosphere.gwt.client.impl.StreamingProtocolTransport
aborted, expectingDisconnection, read
 
Fields inherited from class org.atmosphere.gwt.client.impl.BaseCometTransport
client, connectionId, listener, logger, serverTransport
 
Constructor Summary
HTTPRequestCometTransport()
           
 
Method Summary
 void connect(int connectionCount)
           
 void disconnect()
           
static String getUserAgent()
          Returns the browser's user agent.
protected  boolean needPolling()
           
 
Methods inherited from class org.atmosphere.gwt.client.impl.StreamingProtocolTransport
init, onReceiving
 
Methods inherited from class org.atmosphere.gwt.client.impl.BaseCometTransport
broadcast, broadcast, getServerTransport, getUrl, initiate, parse, post, post
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPRequestCometTransport

public HTTPRequestCometTransport()
Method Detail

connect

public void connect(int connectionCount)

disconnect

public void disconnect()
Specified by:
disconnect in interface CometTransport
Overrides:
disconnect in class BaseCometTransport

needPolling

protected boolean needPolling()

getUserAgent

public static String getUserAgent()
Returns the browser's user agent.

Returns:
the user agent


Copyright © 2011. All Rights Reserved.