Record Class HandshakeMessage

java.lang.Object
java.lang.Record
pt.unl.fct.di.novasys.babel2.channels.messages.HandshakeMessage
Record Components:
identity - the node identity of the sending endpoint

public record HandshakeMessage(BabelNode identity) extends Record
Immutable record exchanged as the very first message on a newly established TCP or QUIC connection to identify both endpoints to each other.

When a connection becomes active, each side immediately sends a HandshakeMessage containing its own BabelNode identity. The receiver uses this identity to register the connection under the canonical address of the remote peer, and uses the node comparator to resolve simultaneous-connection races (the winning node keeps its outbound connection while the other side closes its connection).

The message is encoded by TCPSimpleHandshakeCodec or TCPAuthentitcatedHandshakeCodec (TCP) and QUICHandshakeCodec (QUIC). Codecs prefix the payload with a magic number to distinguish handshake frames from regular Babel message frames on the wire.

  • Constructor Details

    • HandshakeMessage

      public HandshakeMessage(BabelNode identity)
      Creates an instance of a HandshakeMessage record class.
      Parameters:
      identity - the value for the identity record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • identity

      public BabelNode identity()
      Returns the value of the identity record component.
      Returns:
      the value of the identity record component