com.trendrr.oss.networking.strest
Class StrestClient

java.lang.Object
  extended by com.trendrr.oss.networking.strest.StrestClient

public class StrestClient
extends java.lang.Object

Strest Client. This class is threadsafe, and handles low level details of the STREST protocol. The client is implemented using non-blocking sockets, there is a single io thread which is shared across any StrestClient instances. Callbacks are executed in the io thread, so it is recommended that any heavy processing be done in a separate thread.

Author:
Dustin Norlander

Constructor Summary
StrestClient(java.lang.String host, int port)
           
 
Method Summary
 void close()
          closes the connection and cleans up any resources.
 void connect()
           
 StrestResponse sendRequest(StrestRequest request)
          sends a synchronious request, will wait for the result.
 void sendRequest(StrestRequest request, StrestRequestCallback callback)
          sends the request asynchrounously.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StrestClient

public StrestClient(java.lang.String host,
                    int port)
Method Detail

connect

public void connect()
             throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
closes the connection and cleans up any resources. all waiting callbacks will get a disconnected exception..


sendRequest

public void sendRequest(StrestRequest request,
                        StrestRequestCallback callback)
sends the request asynchrounously. this method returns immediately, response is sent to the callback.

Parameters:
request -
callback -
Throws:
java.lang.Exception

sendRequest

public StrestResponse sendRequest(StrestRequest request)
                           throws TrendrrException
sends a synchronious request, will wait for the result.

Parameters:
request -
Returns:
Throws:
TrendrrException