Interface BabelChannel
- All Known Subinterfaces:
BroadcastIPBabelChannel, IPBabelChannel
- All Known Implementing Classes:
AbstractTCPBabelChannel, ComposedBabelChannel, InternalBabelChannel, LegacySimpleServerBabelChannel, QUICBabelChannel, TCPBabelChannel, TLSBabelChannel, UDPBabelChannel
public interface BabelChannel
Represents a communication channel between two Babel runtimes. This interface
only has a single connect method that connects to another Babel runtime.
-
Method Summary
Modifier and TypeMethodDescriptionvoidConnect to another Babel runtime.voiddisconnect(BabelNode peer) Closes the connection topeer.default BabelChannelgetInner()Gets this channel or returns the inner channel if this instance is a wrapper.booleanisConnected(BabelNode peer) Returnstrueif a connection topeeris currently open on this channel.voidsend(BabelNode peer, BabelMessage message) Sends a message through this channel to the given peer using a persistent connection.voidsendEphemeral(BabelNode peer, BabelMessage message) Sends a message topeerwithout establishing a persistent connection.voidshutdown()Releases all resources held by this channel, closing any open connections.
-
Method Details
-
connect
Connect to another Babel runtime. The pecularities of how a channel "connects" to another Babel runtime is up to its implementation. Whether the connection is successful or not, this method should trigger theConnectionUpEventorConnectionFailedEvent. May throwUnsupportedOperationException- Parameters:
peer- the peer to connect to
-
send
Sends a message through this channel to the given peer using a persistent connection. If the connection is not currently open, the message may be queued depending on the implementation.- Parameters:
peer- the peer to send the message tomessage- the message to be sent
-
sendEphemeral
Sends a message topeerwithout establishing a persistent connection. The channel implementation may use a transient transport internally, but none of the connection lifecycle events (connectionUp/connectionDown) are triggered.- Parameters:
peer- the target nodemessage- the message to deliver
-
disconnect
Closes the connection topeer. AConnectionDownEventwill be delivered to interested protocols after the connection has been torn down.- Parameters:
peer- the node to disconnect from
-
isConnected
Returnstrueif a connection topeeris currently open on this channel.- Parameters:
peer- the node whose connection status is queried- Returns:
trueif connected,falseotherwise
-
shutdown
void shutdown()Releases all resources held by this channel, closing any open connections. -
getInner
Gets this channel or returns the inner channel if this instance is a wrapper.- Returns:
- the underlying
BabelChannelinstance
-