Package org.asynchttpclient.ws
Class WebSocketUpgradeHandler
- java.lang.Object
-
- org.asynchttpclient.ws.WebSocketUpgradeHandler
-
- All Implemented Interfaces:
AsyncHandler<NettyWebSocket>
public class WebSocketUpgradeHandler extends Object implements AsyncHandler<NettyWebSocket>
AnAsyncHandler
which is able to execute WebSocket upgrade. Use the Builder for configuring WebSocket options.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WebSocketUpgradeHandler.Builder
Build aWebSocketUpgradeHandler
-
Nested classes/interfaces inherited from interface org.asynchttpclient.AsyncHandler
AsyncHandler.State
-
-
Constructor Summary
Constructors Constructor Description WebSocketUpgradeHandler(List<WebSocketListener> listeners)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncHandler.State
onBodyPartReceived(HttpResponseBodyPart bodyPart)
Invoked as soon as some response body part are received.protected void
onBodyPartReceived0(HttpResponseBodyPart bodyPart)
@Nullable NettyWebSocket
onCompleted()
Invoked once the HTTP response processing is finished.protected void
onCompleted0()
AsyncHandler.State
onHeadersReceived(io.netty.handler.codec.http.HttpHeaders headers)
Invoked as soon as the HTTP headers have been received.protected void
onHeadersReceived0(io.netty.handler.codec.http.HttpHeaders headers)
void
onOpen(NettyWebSocket webSocket)
protected void
onOpen0()
AsyncHandler.State
onStatusReceived(HttpResponseStatus responseStatus)
Invoked as soon as the HTTP status line has been receivedprotected void
onStatusReceived0(HttpResponseStatus responseStatus)
void
onThrowable(Throwable t)
Invoked when an unexpected exception occurs during the processing of the response.protected void
onThrowable0(Throwable t)
void
setWebSocket(NettyWebSocket webSocket)
protected void
setWebSocket0(NettyWebSocket webSocket)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.asynchttpclient.AsyncHandler
onConnectionOffer, onConnectionPoolAttempt, onConnectionPooled, onHostnameResolutionAttempt, onHostnameResolutionFailure, onHostnameResolutionSuccess, onRequestSend, onRetry, onTcpConnectAttempt, onTcpConnectFailure, onTcpConnectSuccess, onTlsHandshakeAttempt, onTlsHandshakeFailure, onTlsHandshakeSuccess, onTrailingHeadersReceived
-
-
-
-
Constructor Detail
-
WebSocketUpgradeHandler
public WebSocketUpgradeHandler(List<WebSocketListener> listeners)
-
-
Method Detail
-
setWebSocket0
protected void setWebSocket0(NettyWebSocket webSocket)
-
onStatusReceived0
protected void onStatusReceived0(HttpResponseStatus responseStatus) throws Exception
- Throws:
Exception
-
onHeadersReceived0
protected void onHeadersReceived0(io.netty.handler.codec.http.HttpHeaders headers) throws Exception
- Throws:
Exception
-
onBodyPartReceived0
protected void onBodyPartReceived0(HttpResponseBodyPart bodyPart) throws Exception
- Throws:
Exception
-
onThrowable0
protected void onThrowable0(Throwable t)
-
onOpen0
protected void onOpen0()
-
onStatusReceived
public final AsyncHandler.State onStatusReceived(HttpResponseStatus responseStatus) throws Exception
Description copied from interface:AsyncHandler
Invoked as soon as the HTTP status line has been received- Specified by:
onStatusReceived
in interfaceAsyncHandler<NettyWebSocket>
- Parameters:
responseStatus
- the status code and test of the response- Returns:
- a
AsyncHandler.State
telling to CONTINUE or ABORT the current processing. - Throws:
Exception
- if something wrong happens
-
onHeadersReceived
public final AsyncHandler.State onHeadersReceived(io.netty.handler.codec.http.HttpHeaders headers) throws Exception
Description copied from interface:AsyncHandler
Invoked as soon as the HTTP headers have been received.- Specified by:
onHeadersReceived
in interfaceAsyncHandler<NettyWebSocket>
- Parameters:
headers
- the HTTP headers.- Returns:
- a
AsyncHandler.State
telling to CONTINUE or ABORT the current processing. - Throws:
Exception
- if something wrong happens
-
onBodyPartReceived
public final AsyncHandler.State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception
Description copied from interface:AsyncHandler
Invoked as soon as some response body part are received. Could be invoked many times. Beware that, depending on the provider (Netty) this can be notified with empty body parts.- Specified by:
onBodyPartReceived
in interfaceAsyncHandler<NettyWebSocket>
- Parameters:
bodyPart
- response's body part.- Returns:
- a
AsyncHandler.State
telling to CONTINUE or ABORT the current processing. Aborting will also close the connection. - Throws:
Exception
- if something wrong happens
-
onCompleted
@Nullable public final @Nullable NettyWebSocket onCompleted() throws Exception
Description copied from interface:AsyncHandler
Invoked once the HTTP response processing is finished.
Gets always invoked as last callback method.- Specified by:
onCompleted
in interfaceAsyncHandler<NettyWebSocket>
- Returns:
- T Value that will be returned by the associated
Future
- Throws:
Exception
- if something wrong happens
-
onThrowable
public final void onThrowable(Throwable t)
Description copied from interface:AsyncHandler
Invoked 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:
onThrowable
in interfaceAsyncHandler<NettyWebSocket>
- Parameters:
t
- aThrowable
-
setWebSocket
public final void setWebSocket(NettyWebSocket webSocket)
-
onOpen
public final void onOpen(NettyWebSocket webSocket)
- Parameters:
webSocket
- this parameter is the same object as the field webSocket, but guaranteed to be not null. This is done to satisfy NullAway requirements
-
-