org.gwtwidgets.server.spring.stream
Class HtmlSLStreamWriterImpl

java.lang.Object
  extended by org.gwtwidgets.server.spring.stream.HtmlSLStreamWriterImpl
All Implemented Interfaces:
SLStreamWriter

public class HtmlSLStreamWriterImpl
extends java.lang.Object
implements SLStreamWriter

Implementation of an SLStreamWriter writing incremental bits of HTML. The intention is that a browser can access via the DOM these messages and decode them. The GWT counterpart of this writer is the HtmlStreamReader.

The protocol explained in short:
A html/body is opened, then each message line consists of a <div> containing the URL-encoded message content and a comma sepperated list of key=value pairs of the message attributes

Some browsers do not start interpreting the streamed content unless the stream is either closed or the transmitted content exceeds a certain size. In order to assure a timely consumption of messages on the client side, this implementation pads messages with more data than might be necessary in certain cases.

Please note that some networks (i.e. when http proxies are involved) may not stream content prior to closing the stream. Furthermore they may impose stricter constraints on a connection's lifetime than planned. For this reasons applications should be prepared to fall back to shorter timeouts.

Author:
George Georgovassilis, g.georgovassilis[at]gmail.com

Constructor Summary
HtmlSLStreamWriterImpl()
           
 
Method Summary
 void close()
           
 void setResponse(javax.servlet.http.HttpServletResponse response)
           
 void setSerialStartpoint(int serial)
           
 void writeMessage(java.lang.String content, java.util.Map<java.lang.String,?> attributes)
          Sends a message to the recipient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlSLStreamWriterImpl

public HtmlSLStreamWriterImpl()
Method Detail

setSerialStartpoint

public void setSerialStartpoint(int serial)

close

public void close()
Specified by:
close in interface SLStreamWriter

setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)

writeMessage

public void writeMessage(java.lang.String content,
                         java.util.Map<java.lang.String,?> attributes)
Description copied from interface: SLStreamWriter
Sends a message to the recipient

Specified by:
writeMessage in interface SLStreamWriter
Parameters:
content - String content of the message
attributes - Metadata of the message, can be any key/value set


Copyright © 2011. All Rights Reserved.