com.appenginefan.toolkit.common
Class ClientSocketSubstitute

java.lang.Object
  extended by com.appenginefan.toolkit.common.ClientSocketSubstitute

public class ClientSocketSubstitute
extends Object

A client-side subsitute for the common pattern of the blocking while(true) readline(); pattern


Constructor Summary
ClientSocketSubstitute(URL url, int silencePeriodInMillis, int maxMessages)
          Constructor.
 
Method Summary
 void close()
          Closes the fake socket
 void println(String snippet)
          Sends a snippet of data to the server.
 String readLine()
          Gets the next line from the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientSocketSubstitute

public ClientSocketSubstitute(URL url,
                              int silencePeriodInMillis,
                              int maxMessages)
Constructor. Uses a simple environment implementation that opens the socket in a new thread and uses URL.openStream() to connect to the WebSocket

Parameters:
url - the URL to connect to
silencePeriodInMillis - the time the thread should wait between each http call
maxMessages - the maximum amount of messages that should be transported in one http request
Method Detail

readLine

public String readLine()
Gets the next line from the server. If nothing is received for 60 seconds, returns null.

Returns:

println

public void println(String snippet)
Sends a snippet of data to the server.


close

public void close()
Closes the fake socket