org.gwtwidgets.client.stream
Class HtmlStreamReader

java.lang.Object
  extended by org.gwtwidgets.client.stream.HtmlStreamReader

public class HtmlStreamReader
extends java.lang.Object

Decodes SL stream protocol messages sent via the HtmlSLStreamWriterImpl. This implementation creates an invisible IFrame which is appended to the current document and polled in intervals. Decoded messages are then removed from the DOM in order to reduce resource consumption.

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

Field Summary
protected  java.util.Date dateOfCreation
           
protected  com.google.gwt.dom.client.IFrameElement frame
           
protected  int lastMessageId
           
protected  long maxAge
           
protected  long pollingInterval
           
protected  com.google.gwt.user.client.Timer timer
           
 
Constructor Summary
HtmlStreamReader()
           
 
Method Summary
 void close()
          Should be called if the client wants to close the stream communication with the server.
protected  com.google.gwt.dom.client.Element getFrame()
           
protected  com.google.gwt.dom.client.Document getFrameContents(com.google.gwt.dom.client.IFrameElement frame)
           
 long getPollingInterval()
           
 void readAsync(java.lang.String url, StreamCallback callback)
          Connects to a URL an starts streaming messages from there.
protected  Message readNextMessage()
           
protected  void reconnect(java.lang.String url, StreamCallback callback)
           
 void setInnerFrameVisibility(boolean status)
          For debugging purposes, can be used to show the IFrame used to receive server messages.
 void setMaxAge(long maxAge)
          Determines the age (in ms) of a connection to a server before closing and refreshing it
 void setPollingInterval(long pollingInterval)
          Sets a polling interval - messages arriving from the server will be decoded every such interval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frame

protected com.google.gwt.dom.client.IFrameElement frame

pollingInterval

protected long pollingInterval

maxAge

protected long maxAge

timer

protected com.google.gwt.user.client.Timer timer

dateOfCreation

protected java.util.Date dateOfCreation

lastMessageId

protected int lastMessageId
Constructor Detail

HtmlStreamReader

public HtmlStreamReader()
Method Detail

getFrameContents

protected com.google.gwt.dom.client.Document getFrameContents(com.google.gwt.dom.client.IFrameElement frame)

readNextMessage

protected Message readNextMessage()

getPollingInterval

public long getPollingInterval()

setPollingInterval

public void setPollingInterval(long pollingInterval)
Sets a polling interval - messages arriving from the server will be decoded every such interval. Please note that this parameter is passed to Timer.schedule(int) which receives an integer argument; hence large values for pollingInterval will not yield the desired behavior.

Parameters:
pollingInterval - Polling interval in milliseconds

getFrame

protected com.google.gwt.dom.client.Element getFrame()

setInnerFrameVisibility

public void setInnerFrameVisibility(boolean status)
For debugging purposes, can be used to show the IFrame used to receive server messages.

Parameters:
status -

readAsync

public void readAsync(java.lang.String url,
                      StreamCallback callback)
Connects to a URL an starts streaming messages from there. Note that despite this being an asynchronous message, the HtmlStreamReader is a stateful object which cannot be used to simultaneously access more resources.

Parameters:
url -
callback -

reconnect

protected void reconnect(java.lang.String url,
                         StreamCallback callback)

close

public void close()
Should be called if the client wants to close the stream communication with the server.


setMaxAge

public void setMaxAge(long maxAge)
Determines the age (in ms) of a connection to a server before closing and refreshing it

Parameters:
maxAge -


Copyright © 2011. All Rights Reserved.