- java.lang.Object
-
- swim.io.AbstractIpModem<I,O>
-
- All Implemented Interfaces:
FlowContext,IpContext,IpModem<I,O>
public abstract class AbstractIpModem<I,O> extends Object implements IpModem<I,O>, IpContext, FlowContext
-
-
Field Summary
Fields Modifier and Type Field Description protected IpModemContext<I,O>context
-
Constructor Summary
Constructors Constructor Description AbstractIpModem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbecome(IpSocket socket)StringcipherSuite()Returns the cryptographic cipher suite used by the underlying network connection.voidclose()voiddidBecome(IpSocket socket)Lifecycle callback invoked by the modem context after it hasbecomea newsocketimplementation.voiddidConnect()Lifecycle callback invoked by the modem context after the underlying network socket has opened a connection.voiddidDisconnect()Lifecycle callback invoked by the socket context after the underlying network connection has disconnected.voiddidFail(Throwable error)Lifecycle callback invoked by the modem context when the underlying network socket fails by throwing anerror.voiddidRead(I input)I/O callback invoked by the modem context with the completed value of the current readDecoderafter it has transitioned to the done state.voiddidSecure()Lifecycle callback invoked by the modem context after the underlying network socket has established a secure connection.voiddidTimeout()Lifecycle callback invoked by the modem context after the underlying network connection has timed out.voiddidWrite(O output)I/O callback invoked by the modem context with the completed value of the current writeEncoderafter it has transitioned to the done state.voiddoRead()voiddoWrite()FlowControlflowControl()Returns the currentFlowControlstate of the underlying network channel.voidflowControl(FlowControl flowControl)Enqueues an atomic replacement of the underlying network channel's flow control state with a newflowControl.FlowControlflowControl(FlowModifier flowModifier)Enqueues an atomic modification to the underlying network channel's flow control state by applying aflowModifierdelta.longidleTimeout()Returns the number of idle milliseconds after which thisIpModemshould be closed due to inactivity.IpModemContext<I,O>ipModemContext()Returns the socket modem context to which thisIpModemis bound; returnsnullif thisIpModemis unbound.IpSettingsipSettings()booleanisClient()Returnstrueif the underlying network channel initiated an outgoing connection.booleanisConnected()Returnstrueif the underlying network channel is currently connected.booleanisSecure()Returnstrueif the underlying network transport is encrypted.booleanisServer()Returnstrueif the underlying network channel accepted an incoming connection.InetSocketAddresslocalAddress()Returns the IP address and port of the local endpoint of the underlying network connection.Collection<Certificate>localCertificates()Returns the certificate chain used to authenticate the local endpoint of the underlying network connection.PrincipallocalPrincipal()Returns the authenticated identity of the local endpoint of the underlying network connection.<I2 extends I>
voidread(Decoder<I2> decoder)InetSocketAddressremoteAddress()Returns the IP address and port of the remote endpoint of the underlying network connection.Collection<Certificate>remoteCertificates()Returns the certificate chain used to authenticate the remote endpoint of the underlying network connection.PrincipalremotePrincipal()Returns the authenticated identity of the remote endpoint of the underlying network connection.StringsecurityProtocol()Returns the name of the transport-layer security protocol used by the underlying network connection.voidsetIpModemContext(IpModemContext<I,O> context)Sets the socket modem context to which thisIpModemis bound.voidwillBecome(IpSocket socket)Lifecycle callback invoked by the modem context before it hasbecomea newsocketimplementation.voidwillConnect()Lifecycle callback invoked by the modem context before the underlying network socket attempts to open a connection.voidwillSecure()Lifecycle callback invoked by the modem context before the underlying network socket establishes a secure connection.<O2 extends O>
voidwrite(Encoder<?,O2> encoder)
-
-
-
Field Detail
-
context
protected IpModemContext<I,O> context
-
-
Method Detail
-
ipModemContext
public IpModemContext<I,O> ipModemContext()
Description copied from interface:IpModemReturns the socket modem context to which thisIpModemis bound; returnsnullif thisIpModemis unbound.- Specified by:
ipModemContextin interfaceIpModem<I,O>
-
setIpModemContext
public void setIpModemContext(IpModemContext<I,O> context)
Description copied from interface:IpModemSets the socket modem context to which thisIpModemis bound.- Specified by:
setIpModemContextin interfaceIpModem<I,O>
-
idleTimeout
public long idleTimeout()
Description copied from interface:IpModemReturns the number of idle milliseconds after which thisIpModemshould be closed due to inactivity. Returns-1if a default idle timeout should be used. Returns0if the underlying network socket should not time out.- Specified by:
idleTimeoutin interfaceIpModem<I,O>
-
doRead
public void doRead()
Description copied from interface:IpModemI/O callback invoked by the modem context asking thisIpModemto provide an inputDecoderby invoking the modem context'sreadmethod. The modem context will asynchronously feed input data to the provided readDecoderuntil it transitions out of the cont state. The read flow control of the underlying network socket is automatically managed by the modem context using the state of the readDecoder. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdoReadordidReadcalls.
-
didRead
public void didRead(I input)
Description copied from interface:IpModemI/O callback invoked by the modem context with the completed value of the current readDecoderafter it has transitioned to the done state. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdoReadordidReadcalls.
-
doWrite
public void doWrite()
Description copied from interface:IpModemI/O callback invoked by the modem context asking thisIpModemto provide an outputEncoderby invoking the modem context'swritemethod. The modem context will asynchronously pull output data from the provided writeEncoderuntil it transitions out of the cont state. The write flow control of the underlying network socket is automatically managed by the modem context using the state of the writeEncoder. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdoWriteordidWritecalls.
-
didWrite
public void didWrite(O output)
Description copied from interface:IpModemI/O callback invoked by the modem context with the completed value of the current writeEncoderafter it has transitioned to the done state. May be invoked concurrently to other I/O callbacks, but never concurrently with otherdodWriteordidWritecalls.
-
willConnect
public void willConnect()
Description copied from interface:IpModemLifecycle callback invoked by the modem context before the underlying network socket attempts to open a connection.- Specified by:
willConnectin interfaceIpModem<I,O>
-
didConnect
public void didConnect()
Description copied from interface:IpModemLifecycle callback invoked by the modem context after the underlying network socket has opened a connection.- Specified by:
didConnectin interfaceIpModem<I,O>
-
willSecure
public void willSecure()
Description copied from interface:IpModemLifecycle callback invoked by the modem context before the underlying network socket establishes a secure connection.- Specified by:
willSecurein interfaceIpModem<I,O>
-
didSecure
public void didSecure()
Description copied from interface:IpModemLifecycle callback invoked by the modem context after the underlying network socket has established a secure connection.
-
willBecome
public void willBecome(IpSocket socket)
Description copied from interface:IpModemLifecycle callback invoked by the modem context before it hasbecomea newsocketimplementation.- Specified by:
willBecomein interfaceIpModem<I,O>
-
didBecome
public void didBecome(IpSocket socket)
Description copied from interface:IpModemLifecycle callback invoked by the modem context after it hasbecomea newsocketimplementation.
-
didTimeout
public void didTimeout()
Description copied from interface:IpModemLifecycle callback invoked by the modem context after the underlying network connection has timed out. The modem will automatically be closed.- Specified by:
didTimeoutin interfaceIpModem<I,O>
-
didDisconnect
public void didDisconnect()
Description copied from interface:IpModemLifecycle callback invoked by the socket context after the underlying network connection has disconnected.- Specified by:
didDisconnectin interfaceIpModem<I,O>
-
didFail
public void didFail(Throwable error)
Description copied from interface:IpModemLifecycle callback invoked by the modem context when the underlying network socket fails by throwing anerror. The modem will automatically be closed.
-
isConnected
public boolean isConnected()
Description copied from interface:IpContextReturnstrueif the underlying network channel is currently connected.- Specified by:
isConnectedin interfaceIpContext
-
isClient
public boolean isClient()
Description copied from interface:IpContextReturnstrueif the underlying network channel initiated an outgoing connection.
-
isServer
public boolean isServer()
Description copied from interface:IpContextReturnstrueif the underlying network channel accepted an incoming connection.
-
isSecure
public boolean isSecure()
Description copied from interface:IpContextReturnstrueif the underlying network transport is encrypted.
-
securityProtocol
public String securityProtocol()
Description copied from interface:IpContextReturns the name of the transport-layer security protocol used by the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not secure.- Specified by:
securityProtocolin interfaceIpContext
-
cipherSuite
public String cipherSuite()
Description copied from interface:IpContextReturns the cryptographic cipher suite used by the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not secure.- Specified by:
cipherSuitein interfaceIpContext
-
localAddress
public InetSocketAddress localAddress()
Description copied from interface:IpContextReturns the IP address and port of the local endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected.- Specified by:
localAddressin interfaceIpContext
-
localPrincipal
public Principal localPrincipal()
Description copied from interface:IpContextReturns the authenticated identity of the local endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.- Specified by:
localPrincipalin interfaceIpContext
-
localCertificates
public Collection<Certificate> localCertificates()
Description copied from interface:IpContextReturns the certificate chain used to authenticate the local endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.- Specified by:
localCertificatesin interfaceIpContext
-
remoteAddress
public InetSocketAddress remoteAddress()
Description copied from interface:IpContextReturns the IP address and port of the remote endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected.- Specified by:
remoteAddressin interfaceIpContext
-
remotePrincipal
public Principal remotePrincipal()
Description copied from interface:IpContextReturns the authenticated identity of the remote endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.- Specified by:
remotePrincipalin interfaceIpContext
-
remoteCertificates
public Collection<Certificate> remoteCertificates()
Description copied from interface:IpContextReturns the certificate chain used to authenticate the remote endpoint of the underlying network connection. Returnsnullif the underlying network channel is not currently connected, or if the underlying network connection is not authenticated.- Specified by:
remoteCertificatesin interfaceIpContext
-
flowControl
public FlowControl flowControl()
Description copied from interface:FlowContextReturns the currentFlowControlstate of the underlying network channel.- Specified by:
flowControlin interfaceFlowContext
-
flowControl
public void flowControl(FlowControl flowControl)
Description copied from interface:FlowContextEnqueues an atomic replacement of the underlying network channel's flow control state with a newflowControl.- Specified by:
flowControlin interfaceFlowContext
-
flowControl
public FlowControl flowControl(FlowModifier flowModifier)
Description copied from interface:FlowContextEnqueues an atomic modification to the underlying network channel's flow control state by applying aflowModifierdelta.- Specified by:
flowControlin interfaceFlowContext
-
ipSettings
public IpSettings ipSettings()
-
become
public void become(IpSocket socket)
-
close
public void close()
-
-