org.atmosphere.wasync.transport
Class StreamTransport

java.lang.Object
  extended by org.atmosphere.wasync.transport.StreamTransport
All Implemented Interfaces:
com.ning.http.client.AsyncHandler<String>, Transport
Direct Known Subclasses:
LongPollingTransport, SSETransport

public class StreamTransport
extends Object
implements com.ning.http.client.AsyncHandler<String>, Transport

Streaming Transport implementation

Author:
Jeanfrancois Arcand

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ning.http.client.AsyncHandler
com.ning.http.client.AsyncHandler.STATE
 
Field Summary
protected  String charSet
           
protected  AtomicBoolean closed
           
protected  Future connectdFuture
           
protected  List<Decoder<? extends Object,?>> decoders
           
protected  AtomicBoolean errorHandled
           
protected  List<FunctionWrapper> functions
           
protected  boolean isBinary
           
protected  Options options
           
protected  boolean protocolEnabled
           
protected  boolean protocolReceived
           
protected  Request request
           
protected  com.ning.http.client.RequestBuilder requestBuilder
           
protected  FunctionResolver resolver
           
protected  Socket.STATUS status
           
protected  com.ning.http.client.ListenableFuture underlyingFuture
           
 
Constructor Summary
StreamTransport(com.ning.http.client.RequestBuilder requestBuilder, Options options, Request request, List<FunctionWrapper> functions)
           
 
Method Summary
 void close()
          Close the underlying transport}
 void connectedFuture(Future f)
          Set the Future, which will unlock the Socket.fire(java.lang.Object) method once the connection has been fully established.
 void error(Throwable t)
          Set a Throwable
 boolean errorHandled()
          Error handled by a Function
 void future(com.ning.http.client.ListenableFuture f)
          Set the ListenableFuture, which can be used to clone the connection.
 Request.TRANSPORT name()
          The transport name
 com.ning.http.client.AsyncHandler.STATE onBodyPartReceived(com.ning.http.client.HttpResponseBodyPart bodyPart)
          
 String onCompleted()
          
 com.ning.http.client.AsyncHandler.STATE onHeadersReceived(com.ning.http.client.HttpResponseHeaders headers)
          
 com.ning.http.client.AsyncHandler.STATE onStatusReceived(com.ning.http.client.HttpResponseStatus responseStatus)
          
 void onThrowable(Throwable t)
          Called when an unexpected exception ocurred.
 Transport registerF(FunctionWrapper function)
          Register a new FunctionResolver
 Socket.STATUS status()
          Return the current Socket.STATUS
protected static boolean whiteSpace(byte[] b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

functions

protected final List<FunctionWrapper> functions

decoders

protected final List<Decoder<? extends Object,?>> decoders

charSet

protected String charSet

resolver

protected final FunctionResolver resolver

options

protected final Options options

requestBuilder

protected final com.ning.http.client.RequestBuilder requestBuilder

request

protected final Request request

closed

protected final AtomicBoolean closed

isBinary

protected final boolean isBinary

status

protected Socket.STATUS status

errorHandled

protected final AtomicBoolean errorHandled

underlyingFuture

protected com.ning.http.client.ListenableFuture underlyingFuture

protocolReceived

protected boolean protocolReceived

connectdFuture

protected Future connectdFuture

protocolEnabled

protected final boolean protocolEnabled
Constructor Detail

StreamTransport

public StreamTransport(com.ning.http.client.RequestBuilder requestBuilder,
                       Options options,
                       Request request,
                       List<FunctionWrapper> functions)
Method Detail

registerF

public Transport registerF(FunctionWrapper function)
Register a new FunctionResolver

Specified by:
registerF in interface Transport
Parameters:
function - FunctionResolver
Returns:
this;

onThrowable

public void onThrowable(Throwable t)
Called when an unexpected exception ocurred.

Specified by:
onThrowable in interface com.ning.http.client.AsyncHandler<String>
Specified by:
onThrowable in interface Transport
Parameters:
t - a Throwable

onBodyPartReceived

public com.ning.http.client.AsyncHandler.STATE onBodyPartReceived(com.ning.http.client.HttpResponseBodyPart bodyPart)
                                                           throws Exception

Specified by:
onBodyPartReceived in interface com.ning.http.client.AsyncHandler<String>
Throws:
Exception

onHeadersReceived

public com.ning.http.client.AsyncHandler.STATE onHeadersReceived(com.ning.http.client.HttpResponseHeaders headers)
                                                          throws Exception

Specified by:
onHeadersReceived in interface com.ning.http.client.AsyncHandler<String>
Throws:
Exception

onStatusReceived

public com.ning.http.client.AsyncHandler.STATE onStatusReceived(com.ning.http.client.HttpResponseStatus responseStatus)
                                                         throws Exception

Specified by:
onStatusReceived in interface com.ning.http.client.AsyncHandler<String>
Throws:
Exception

onCompleted

public String onCompleted()
                   throws Exception

Specified by:
onCompleted in interface com.ning.http.client.AsyncHandler<String>
Throws:
Exception

name

public Request.TRANSPORT name()
The transport name

Specified by:
name in interface Transport
Returns:
transport name

close

public void close()
Close the underlying transport}

Specified by:
close in interface Transport

status

public Socket.STATUS status()
Return the current Socket.STATUS

Specified by:
status in interface Transport

errorHandled

public boolean errorHandled()
Error handled by a Function

Specified by:
errorHandled in interface Transport

error

public void error(Throwable t)
Set a Throwable

Specified by:
error in interface Transport
Parameters:
t - Throwable

future

public void future(com.ning.http.client.ListenableFuture f)
Set the ListenableFuture, which can be used to clone the connection.

Specified by:
future in interface Transport
Parameters:
f - ListenableFuture

connectedFuture

public void connectedFuture(Future f)
Description copied from interface: Transport
Set the Future, which will unlock the Socket.fire(java.lang.Object) method once the connection has been fully established.

Specified by:
connectedFuture in interface Transport
Parameters:
f - Future

whiteSpace

protected static final boolean whiteSpace(byte[] b)


Copyright © 2013. All Rights Reserved.