public final class Connection extends Object
| Constructor and Description |
|---|
Connection(InetSocketAddress peerAddress,
org.eclipse.californium.elements.util.SerialExecutor serialExecutor)
Creates a new connection to a given peer.
|
Connection(SessionTicket sessionTicket,
SessionId sessionId,
InetSocketAddress peerAddress)
Creates a new connection from a session ticket containing current state from another
connection that should be resumed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(Record record)
Close connection with record.
|
boolean |
equalsPeerAddress(InetSocketAddress peerAddress)
Check, if the provided address is the peers address.
|
boolean |
expectCid()
Check, if this connection expects connection ID for incoming records.
|
ConnectionId |
getConnectionId()
Gets the connection id.
|
DTLSSession |
getEstablishedSession()
Gets the already established DTLS session that exists with this connection's peer.
|
org.eclipse.californium.elements.util.SerialExecutor |
getExecutor()
Gets the serial executor assigned to this connection.
|
long |
getLastPeerAddressNanos()
Get real time nanoseconds of last
updatePeerAddress(InetSocketAddress). |
Handshaker |
getOngoingHandshake()
Gets the handshaker managing the currently ongoing handshake with the peer.
|
InetSocketAddress |
getPeerAddress()
Gets the address of this connection's peer.
|
AlertMessage |
getRootCauseAlert()
Gets the root cause alert.
|
InetSocketAddress |
getRouter()
Gets the address of this connection's router.
|
DTLSSession |
getSession()
Gets the session containing the connection's current state.
|
DTLSSession |
getSession(int readEpoch)
Gets the session containing the connection's current state for
the provided epoch.
|
SessionId |
getSessionIdentity()
Gets the session identity this connection can be resumed from.
|
SessionListener |
getSessionListener()
Get session listener of connection.
|
SessionTicket |
getSessionTicket()
Gets the session ticket this connection can be resumed from.
|
boolean |
hasEstablishedSession()
Checks whether a session has already been established with the peer.
|
boolean |
hasOngoingHandshake()
Checks whether there is a handshake going on with the peer.
|
boolean |
isActive()
Checks whether this connection is either in use on this node or can be resumed by peers interacting with
this node.
|
boolean |
isAutoResumptionRequired(Long autoResumptionTimeoutMillis)
Check, if the automatic session resumption should be triggered or is
already required.
|
boolean |
isClosed()
Check, if connection was closed.
|
boolean |
isExecuting()
Checks, if the connection has a executing serial executor.
|
boolean |
isResumptionRequired()
Check, if resumption is required.
|
boolean |
isStartedByClientHello(ClientHello clientHello)
Checks whether this connection is started for the provided CLIENT_HELLO.
|
void |
refreshAutoResumptionTime()
Refresh auto resumption timeout.
|
void |
resetSession()
Reset session.
|
void |
setConnectionId(ConnectionId cid)
Sets the connection id.
|
void |
setExecutionListener(ConnectionExecutionListener listener) |
void |
setExecutor(org.eclipse.californium.elements.util.SerialExecutor serialExecutor)
Set new executor to restart execution for stopped connection.
|
void |
setResumptionRequired(boolean resumptionRequired)
Use to force an abbreviated handshake next time a data will be sent on this connection.
|
void |
setRootCause(AlertMessage rootCause)
Sets root cause alert.
|
void |
setRouter(InetSocketAddress router)
Sets the address of this connection's router.
|
void |
startByClientHello(ClientHello clientHello)
Set starting CLIENT_HELLO.
|
String |
toString() |
void |
updateConnectionState() |
void |
updatePeerAddress(InetSocketAddress peerAddress)
Update the address of this connection's peer.
|
public Connection(InetSocketAddress peerAddress, org.eclipse.californium.elements.util.SerialExecutor serialExecutor)
peerAddress - the IP address and port of the peer the connection exists withserialExecutor - serial executor.NullPointerException - if the peer address or the serial executor is nullpublic Connection(SessionTicket sessionTicket, SessionId sessionId, InetSocketAddress peerAddress)
isExecuting().sessionTicket - The other connection's current state.sessionId - The other connection's session id.peerAddress - optional peer address for ClientSessionCache.
May be null.NullPointerException - if the session ticket or id is nullpublic void setExecutionListener(ConnectionExecutionListener listener)
public void updateConnectionState()
public void setExecutor(org.eclipse.californium.elements.util.SerialExecutor serialExecutor)
serialExecutor - new serial executorNullPointerException - if the serial executor is nullIllegalStateException - if the connection is already executingpublic org.eclipse.californium.elements.util.SerialExecutor getExecutor()
null, if the connection was
created with Connection(SessionTicket, SessionId, InetSocketAddress).public boolean isExecuting()
true, if the connection has an executing serial executor.
false, if no serial executor is available, or the
executor is shutdown.public final SessionListener getSessionListener()
public boolean isActive()
A connection that is not active is currently being negotiated by means of the ongoingHandshake.
true if this connection either already has an established session or
contains a session ticket that it can be resumed from.public SessionId getSessionIdentity()
null if this connection has not been created from a session ticket.public SessionTicket getSessionTicket()
null if this connection has not been created from a session ticket.public boolean expectCid()
true, if connection ID is expected, false,
otherwisepublic ConnectionId getConnectionId()
public void setConnectionId(ConnectionId cid)
cid - the connection idpublic long getLastPeerAddressNanos()
updatePeerAddress(InetSocketAddress).ClockUtil.nanoRealtime()public InetSocketAddress getPeerAddress()
public void updatePeerAddress(InetSocketAddress peerAddress)
null, an ongoing handshake is failed. A
non-null address could only be applied, if the session is established.
Note: to keep track of the associated address in the connection store,
this method must not be called directly. It must be called by calling
ResumptionSupportingConnectionStore.update(Connection, InetSocketAddress)
or
ResumptionSupportingConnectionStore.remove(Connection, boolean).peerAddress - the address of the peerIllegalArgumentException - if the address should be updated with a
non-null value without an established session.public boolean equalsPeerAddress(InetSocketAddress peerAddress)
peerAddress - provided peer addresstrue, if the addresses are equalpublic InetSocketAddress getRouter()
public void setRouter(InetSocketAddress router)
router - the address of the routerpublic DTLSSession getEstablishedSession()
null if no session has been established (yet)public boolean hasEstablishedSession()
true if a session has been establishedpublic Handshaker getOngoingHandshake()
null if no handshake is going onpublic boolean hasOngoingHandshake()
true if a handshake is going onpublic boolean isStartedByClientHello(ClientHello clientHello)
clientHello - the message to check.true if the given client hello has initially started this
connection.NullPointerException - if client hello is null.startByClientHello(ClientHello)public void startByClientHello(ClientHello clientHello)
clientHello - message which starts the connection.isStartedByClientHello(ClientHello)public DTLSSession getSession(int readEpoch)
establishedSession, if not null and the read
epoch is matching. Or the session negotiated in the
ongoingHandshake, if not null and the read epoch is
matching. If both are null, or the read epoch doesn't match,
null is returned.readEpoch - the read epoch to match.null, if neither an
established session nor an ongoing handshake exists with an
matching read epochpublic DTLSSession getSession()
establishedSession if not null or the
session negotiated in the ongoingHandshake.null if neither an
established session nor an ongoing handshake existspublic void resetSession()
IllegalStateException - if neither a established session nor a
ticket is availablepublic boolean isClosed()
true, if connection was closed, false, otherwise.public void close(Record record)
record - received close notify record.public AlertMessage getRootCauseAlert()
public void setRootCause(AlertMessage rootCause)
rootCause - root cause alertpublic boolean isResumptionRequired()
true, if an abbreviated handshake should be done next time a data
will be sent on this connection.public boolean isAutoResumptionRequired(Long autoResumptionTimeoutMillis)
autoResumptionTimeoutMillis - auto resumption timeout in
milliseconds. null, if auto resumption is not used.true, if the provided autoResumptionTimeoutMillis has
expired without exchanging messages.public void refreshAutoResumptionTime()
ClockUtil.nanoRealtime().lastMessageNanospublic void setResumptionRequired(boolean resumptionRequired)
resumptionRequired - true to force abbreviated handshake.Copyright © 2023 Eclipse Foundation. All rights reserved.