public abstract class ProxyHandler extends ChannelDuplexHandler
ChannelHandler.Sharable| 限定符 | 构造器和说明 |
|---|---|
protected |
ProxyHandler(java.net.SocketAddress proxyAddress) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected abstract void |
addCodec(ChannelHandlerContext ctx)
Adds the codec handlers required to communicate with the proxy server.
|
abstract java.lang.String |
authScheme()
Returns the name of the authentication scheme in use.
|
void |
channelActive(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelActive() to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
void |
channelInactive(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
void |
channelRead(ChannelHandlerContext ctx,
java.lang.Object msg)
Calls
ChannelHandlerContext.fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
void |
channelReadComplete(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelReadComplete() to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
void |
connect(ChannelHandlerContext ctx,
java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress,
ChannelPromise promise)
Calls
ChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline. |
Future<Channel> |
connectFuture()
Returns a
Future that is notified when the connection to the destination has been established
or the connection attempt has failed. |
long |
connectTimeoutMillis()
Returns the connect timeout in millis.
|
<T extends java.net.SocketAddress> |
destinationAddress()
Returns the address of the destination to connect to via the proxy server.
|
void |
exceptionCaught(ChannelHandlerContext ctx,
java.lang.Throwable cause)
Calls
ChannelHandlerContext.fireExceptionCaught(Throwable) to forward
to the next ChannelHandler in the ChannelPipeline. |
protected java.lang.String |
exceptionMessage(java.lang.String msg)
Decorates the specified exception message with the common information such as the current protocol,
authentication scheme, proxy address, and destination address.
|
void |
flush(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.flush() to forward
to the next ChannelOutboundHandler in the ChannelPipeline. |
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
protected abstract boolean |
handleResponse(ChannelHandlerContext ctx,
java.lang.Object response)
Handles the message received from the proxy server.
|
boolean |
isConnected()
Returns
true if and only if the connection to the destination has been established successfully. |
protected abstract java.lang.Object |
newInitialMessage(ChannelHandlerContext ctx)
Returns a new message that is sent at first time when the connection to the proxy server has been established.
|
abstract java.lang.String |
protocol()
Returns the name of the proxy protocol in use.
|
<T extends java.net.SocketAddress> |
proxyAddress()
Returns the address of the proxy server.
|
protected abstract void |
removeDecoder(ChannelHandlerContext ctx)
Removes the decoders added in
addCodec(ChannelHandlerContext). |
protected abstract void |
removeEncoder(ChannelHandlerContext ctx)
Removes the encoders added in
addCodec(ChannelHandlerContext). |
protected void |
sendToProxyServer(java.lang.Object msg)
Sends the specified message to the proxy server.
|
void |
setConnectTimeoutMillis(long connectTimeoutMillis)
Sets the connect timeout in millis.
|
void |
write(ChannelHandlerContext ctx,
java.lang.Object msg,
ChannelPromise promise)
Calls
ChannelOutboundInvoker.write(Object, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline. |
bind, close, deregister, disconnect, readchannelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, handlerRemoved, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerRemovedpublic abstract java.lang.String protocol()
public abstract java.lang.String authScheme()
public final <T extends java.net.SocketAddress> T proxyAddress()
public final <T extends java.net.SocketAddress> T destinationAddress()
public final boolean isConnected()
true if and only if the connection to the destination has been established successfully.public final Future<Channel> connectFuture()
Future that is notified when the connection to the destination has been established
or the connection attempt has failed.public final long connectTimeoutMillis()
public final void setConnectTimeoutMillis(long connectTimeoutMillis)
public final void handlerAdded(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelHandlerAdapterhandlerAdded 在接口中 ChannelHandlerhandlerAdded 在类中 ChannelHandlerAdapterjava.lang.Exceptionprotected abstract void addCodec(ChannelHandlerContext ctx) throws java.lang.Exception
java.lang.Exceptionprotected abstract void removeEncoder(ChannelHandlerContext ctx) throws java.lang.Exception
addCodec(ChannelHandlerContext).java.lang.Exceptionprotected abstract void removeDecoder(ChannelHandlerContext ctx) throws java.lang.Exception
addCodec(ChannelHandlerContext).java.lang.Exceptionpublic final void connect(ChannelHandlerContext ctx, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise) throws java.lang.Exception
ChannelDuplexHandlerChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.connect 在接口中 ChannelOutboundHandlerconnect 在类中 ChannelDuplexHandlerctx - the ChannelHandlerContext for which the connect operation is maderemoteAddress - the SocketAddress to which it should connectlocalAddress - the SocketAddress which is used as source on connectpromise - the ChannelPromise to notify once the operation completesjava.lang.Exception - thrown if an error occurspublic final void channelActive(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelActive() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelActive 在接口中 ChannelInboundHandlerchannelActive 在类中 ChannelInboundHandlerAdapterjava.lang.Exceptionprotected abstract java.lang.Object newInitialMessage(ChannelHandlerContext ctx) throws java.lang.Exception
null if the proxy server is expected to send the first message insteadjava.lang.Exceptionprotected final void sendToProxyServer(java.lang.Object msg)
handleResponse(ChannelHandlerContext, Object).public final void channelInactive(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelInactive 在接口中 ChannelInboundHandlerchannelInactive 在类中 ChannelInboundHandlerAdapterjava.lang.Exceptionpublic final void exceptionCaught(ChannelHandlerContext ctx, java.lang.Throwable cause) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireExceptionCaught(Throwable) to forward
to the next ChannelHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.exceptionCaught 在接口中 ChannelHandlerexceptionCaught 在接口中 ChannelInboundHandlerexceptionCaught 在类中 ChannelInboundHandlerAdapterjava.lang.Exceptionpublic final void channelRead(ChannelHandlerContext ctx, java.lang.Object msg) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelRead 在接口中 ChannelInboundHandlerchannelRead 在类中 ChannelInboundHandlerAdapterjava.lang.Exceptionprotected abstract boolean handleResponse(ChannelHandlerContext ctx, java.lang.Object response) throws java.lang.Exception
true if the connection to the destination has been established,
false if the connection to the destination has not been established and more messages are
expected from the proxy serverjava.lang.Exceptionprotected final java.lang.String exceptionMessage(java.lang.String msg)
public final void channelReadComplete(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelReadComplete() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelReadComplete 在接口中 ChannelInboundHandlerchannelReadComplete 在类中 ChannelInboundHandlerAdapterjava.lang.Exceptionpublic final void write(ChannelHandlerContext ctx, java.lang.Object msg, ChannelPromise promise) throws java.lang.Exception
ChannelDuplexHandlerChannelOutboundInvoker.write(Object, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.write 在接口中 ChannelOutboundHandlerwrite 在类中 ChannelDuplexHandlerctx - the ChannelHandlerContext for which the write operation is mademsg - the message to writepromise - the ChannelPromise to notify once the operation completesjava.lang.Exception - thrown if an error occurspublic final void flush(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelDuplexHandlerChannelHandlerContext.flush() to forward
to the next ChannelOutboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.flush 在接口中 ChannelOutboundHandlerflush 在类中 ChannelDuplexHandlerctx - the ChannelHandlerContext for which the flush operation is madejava.lang.Exception - thrown if an error occurs