Record Class IceCandidate

java.lang.Object
java.lang.Record
com.hypixel.hytale.server.core.io.ice.IceCandidate

public record IceCandidate(@Nonnull IceCandidate.Type type, @Nonnull InetSocketAddress address, long priority, @Nonnull String foundation) extends Record
A transport address this host can be reached at, with the priority that orders checks against it.
See Also:
  • Field Details

    • COMPONENT_ID

      public static final int COMPONENT_ID
      Only one component is used: a single QUIC connection, unlike media that splits RTP and RTCP.
      See Also:
    • MAX_PRIORITY

      public static final long MAX_PRIORITY
      Highest priority the formula can produce. Anything above it, or at or beyond 2^31, could not have come from a legal computation and is refused rather than trusted.
      See Also:
    • PEER_REFLEXIVE_PRIORITY

      public static final long PEER_REFLEXIVE_PRIORITY
      Priority used for a check whose pair was learned from the peer rather than advertised.
  • Constructor Details

    • IceCandidate

      public IceCandidate(@Nonnull IceCandidate.Type type, @Nonnull InetSocketAddress address, long priority, @Nonnull String foundation)
      Creates an instance of a IceCandidate record class.
      Parameters:
      type - the value for the type record component
      address - the value for the address record component
      priority - the value for the priority record component
      foundation - the value for the foundation record component
  • Method Details

    • computePriority

      public static long computePriority(@Nonnull IceCandidate.Type type, int localPreference)
    • isValidPriority

      public static boolean isValidPriority(long priority)
      Whether a peer-supplied priority could have come from the formula.

      Priority is unsigned on the wire. Java has no unsigned int, so a value at or above 2^31 would read as negative and sort checks in the wrong order; it is refused at the boundary instead.

    • host

      public static IceCandidate host(@Nonnull InetSocketAddress address)
    • serverReflexive

      public static IceCandidate serverReflexive(@Nonnull InetSocketAddress address)
      A candidate for the address a socket appears to have from outside its own network.
      Parameters:
      address - the address a STUN server reported, not the one the socket is bound to
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • type

      @Nonnull public IceCandidate.Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • address

      @Nonnull public InetSocketAddress address()
      Returns the value of the address record component.
      Returns:
      the value of the address record component
    • priority

      public long priority()
      Returns the value of the priority record component.
      Returns:
      the value of the priority record component
    • foundation

      @Nonnull public String foundation()
      Returns the value of the foundation record component.
      Returns:
      the value of the foundation record component