Package com.ning.http.client.ws
Class WebSocketUpgradeHandler
java.lang.Object
com.ning.http.client.ws.WebSocketUpgradeHandler
- All Implemented Interfaces:
AsyncHandler<WebSocket>,UpgradeHandler<WebSocket>
public class WebSocketUpgradeHandler
extends Object
implements UpgradeHandler<WebSocket>, AsyncHandler<WebSocket>
An
AsyncHandler which is able to execute WebSocket upgrade. Use the Builder for configuring WebSocket options.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.ning.http.client.AsyncHandler
AsyncHandler.STATE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedWebSocketUpgradeHandler(List<WebSocketListener> listeners) -
Method Summary
Modifier and TypeMethodDescriptiononBodyPartReceived(HttpResponseBodyPart bodyPart) Invoked as soon as some response body part are received.voidInvoked once the HTTP response processing is finished.voidIf the upgrade fail.onHeadersReceived(HttpResponseHeaders headers) Invoked as soon as the HTTP headers has been received.onStatusReceived(HttpResponseStatus responseStatus) Invoked as soon as the HTTP status line has been receivedvoidIf the HTTP Upgrade succeed (response's status code equals 101), theAsyncHttpProviderwill invoke that methodvoidInvoked when an unexpected exception occurs during the processing of the response.boolean
-
Constructor Details
-
WebSocketUpgradeHandler
protected WebSocketUpgradeHandler() -
WebSocketUpgradeHandler
-
-
Method Details
-
onThrowable
Description copied from interface:AsyncHandlerInvoked when an unexpected exception occurs during the processing of the response. The exception may have been produced by implementation of onXXXReceived method invocation.- Specified by:
onThrowablein interfaceAsyncHandler<WebSocket>- Parameters:
t- aThrowable
-
touchSuccess
public boolean touchSuccess() -
onBodyPartReceived
Description copied from interface:AsyncHandlerInvoked as soon as some response body part are received. Could be invoked many times.- Specified by:
onBodyPartReceivedin interfaceAsyncHandler<WebSocket>- Parameters:
bodyPart- response's body part.- Returns:
- a
AsyncHandler.STATEtelling to CONTINUE or ABORT the current processing. - Throws:
Exception- if something wrong happens
-
onStatusReceived
Description copied from interface:AsyncHandlerInvoked as soon as the HTTP status line has been received- Specified by:
onStatusReceivedin interfaceAsyncHandler<WebSocket>- Parameters:
responseStatus- the status code and test of the response- Returns:
- a
AsyncHandler.STATEtelling to CONTINUE or ABORT the current processing. - Throws:
Exception- if something wrong happens
-
onHeadersReceived
Description copied from interface:AsyncHandlerInvoked as soon as the HTTP headers has been received. Can potentially be invoked more than once if a broken server sent trailing headers.- Specified by:
onHeadersReceivedin interfaceAsyncHandler<WebSocket>- Parameters:
headers- the HTTP headers.- Returns:
- a
AsyncHandler.STATEtelling to CONTINUE or ABORT the current processing. - Throws:
Exception- if something wrong happens
-
onCompleted
Description copied from interface:AsyncHandlerInvoked once the HTTP response processing is finished. Gets always invoked as last callback method.- Specified by:
onCompletedin interfaceAsyncHandler<WebSocket>- Returns:
- T Value that will be returned by the associated
Future - Throws:
Exception- if something wrong happens
-
onSuccess
Description copied from interface:UpgradeHandlerIf the HTTP Upgrade succeed (response's status code equals 101), theAsyncHttpProviderwill invoke that method- Specified by:
onSuccessin interfaceUpgradeHandler<WebSocket>- Parameters:
webSocket- an Upgradable entity
-
onFailure
Description copied from interface:UpgradeHandlerIf the upgrade fail.- Specified by:
onFailurein interfaceUpgradeHandler<WebSocket>- Parameters:
t- aThrowable
-
onClose
-