org.atmosphere.wasync.transport
Class WebSocketTransport

java.lang.Object
  extended by com.ning.http.client.websocket.WebSocketUpgradeHandler
      extended by org.atmosphere.wasync.transport.WebSocketTransport
All Implemented Interfaces:
com.ning.http.client.AsyncHandler<com.ning.http.client.websocket.WebSocket>, com.ning.http.client.UpgradeHandler<com.ning.http.client.websocket.WebSocket>, Transport

public class WebSocketTransport
extends com.ning.http.client.websocket.WebSocketUpgradeHandler
implements Transport

WebSocket Transport implementation

Author:
Jeanfrancois Arcand

Nested Class Summary
 
Nested classes/interfaces inherited from class com.ning.http.client.websocket.WebSocketUpgradeHandler
com.ning.http.client.websocket.WebSocketUpgradeHandler.Builder
 
Nested classes/interfaces inherited from interface com.ning.http.client.AsyncHandler
com.ning.http.client.AsyncHandler.STATE
 
Field Summary
protected  boolean protocolEnabled
           
protected  boolean supportBinary
           
protected  java.util.concurrent.ScheduledExecutorService timer
           
 
Constructor Summary
WebSocketTransport(com.ning.http.client.RequestBuilder requestBuilder, Options options, Request request, java.util.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(java.lang.Throwable t)
          Set a Throwable
 boolean errorHandled()
          Error handled by a Function
 void future(Future f)
          Set the Future, 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)
          
 com.ning.http.client.websocket.WebSocket onCompleted()
          
 void onFailure(java.lang.Throwable t)
          
 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 onSuccess(com.ning.http.client.websocket.WebSocket webSocket)
          
 void onThrowable(java.lang.Throwable t)
          Called when an unexpected exception ocurred.
 Transport registerF(FunctionWrapper function)
          Register a new FunctionResolver
 WebSocketTransport sendMessage(byte[] message)
           
 WebSocketTransport sendMessage(java.lang.String message)
           
 Socket.STATUS status()
          Return the current Socket.STATUS
 
Methods inherited from class com.ning.http.client.websocket.WebSocketUpgradeHandler
onClose, resetSuccess, touchSuccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

protocolEnabled

protected final boolean protocolEnabled

supportBinary

protected boolean supportBinary

timer

protected final java.util.concurrent.ScheduledExecutorService timer
Constructor Detail

WebSocketTransport

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

onThrowable

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

Specified by:
onThrowable in interface com.ning.http.client.AsyncHandler<com.ning.http.client.websocket.WebSocket>
Specified by:
onThrowable in interface Transport
Overrides:
onThrowable in class com.ning.http.client.websocket.WebSocketUpgradeHandler
Parameters:
t - a Throwable

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(java.lang.Throwable t)
Set a Throwable

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

future

public void future(Future f)
Set the Future, which can be used to clone the connection.

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

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

onBodyPartReceived

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

Specified by:
onBodyPartReceived in interface com.ning.http.client.AsyncHandler<com.ning.http.client.websocket.WebSocket>
Overrides:
onBodyPartReceived in class com.ning.http.client.websocket.WebSocketUpgradeHandler
Throws:
java.lang.Exception

onStatusReceived

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

Specified by:
onStatusReceived in interface com.ning.http.client.AsyncHandler<com.ning.http.client.websocket.WebSocket>
Overrides:
onStatusReceived in class com.ning.http.client.websocket.WebSocketUpgradeHandler
Throws:
java.lang.Exception

onHeadersReceived

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

Specified by:
onHeadersReceived in interface com.ning.http.client.AsyncHandler<com.ning.http.client.websocket.WebSocket>
Overrides:
onHeadersReceived in class com.ning.http.client.websocket.WebSocketUpgradeHandler
Throws:
java.lang.Exception

onCompleted

public com.ning.http.client.websocket.WebSocket onCompleted()
                                                     throws java.lang.Exception

Specified by:
onCompleted in interface com.ning.http.client.AsyncHandler<com.ning.http.client.websocket.WebSocket>
Overrides:
onCompleted in class com.ning.http.client.websocket.WebSocketUpgradeHandler
Throws:
java.lang.Exception

onSuccess

public void onSuccess(com.ning.http.client.websocket.WebSocket webSocket)

Specified by:
onSuccess in interface com.ning.http.client.UpgradeHandler<com.ning.http.client.websocket.WebSocket>
Overrides:
onSuccess in class com.ning.http.client.websocket.WebSocketUpgradeHandler

name

public Request.TRANSPORT name()
The transport name

Specified by:
name in interface Transport
Returns:
transport name

registerF

public Transport registerF(FunctionWrapper function)
Register a new FunctionResolver

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

onFailure

public final void onFailure(java.lang.Throwable t)

Specified by:
onFailure in interface com.ning.http.client.UpgradeHandler<com.ning.http.client.websocket.WebSocket>
Overrides:
onFailure in class com.ning.http.client.websocket.WebSocketUpgradeHandler

sendMessage

public WebSocketTransport sendMessage(java.lang.String message)

sendMessage

public WebSocketTransport sendMessage(byte[] message)


Copyright © 2014. All Rights Reserved.