Class NetherNetHTTPSignaling

java.lang.Object
org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetHTTPSignaling
All Implemented Interfaces:
AutoCloseable, NetherNetServerSignaling, NetherNetSignaling

public class NetherNetHTTPSignaling extends Object implements NetherNetServerSignaling
This class implements a signaling server using HTTP(S) for the NetherNet protocol.

Follows ...

  • Method Details

    • bind

      public void bind(SocketAddress localAddress, io.netty.channel.EventLoop eventLoop) throws ConnectException
      Description copied from interface: NetherNetServerSignaling
      Binds the signaling medium to listen for incoming connections (Server mode).
      Specified by:
      bind in interface NetherNetServerSignaling
      Parameters:
      localAddress - The local address to bind to.
      eventLoop - The owning channel's event loop.
      Throws:
      ConnectException
    • setNewConnectionHandler

      public void setNewConnectionHandler(NetherNetServerSignaling.NewConnectionHandler handler)
      Description copied from interface: NetherNetServerSignaling
      Handler for new connections.
      Specified by:
      setNewConnectionHandler in interface NetherNetServerSignaling
      Parameters:
      handler - Functional interface receiving (ConnectionID, RemoteNetworkID, Payload)
    • setAdvertisementData

      public void setAdvertisementData(NetherNetServerSignaling.PongData pongData)
      Description copied from interface: NetherNetServerSignaling
      Sets the advertisement data for the discovery mechanism (e.g. LAN Pong).
      Specified by:
      setAdvertisementData in interface NetherNetServerSignaling
      Parameters:
      pongData - The Pong advertisement data.
    • serverIdentity

      public ServerIdentity serverIdentity()
      Description copied from interface: NetherNetServerSignaling
      Returns the identity used to sign SDP answers, or null to have the channel generate an ephemeral one.
      Specified by:
      serverIdentity in interface NetherNetServerSignaling
      Returns:
      The server identity, or null if this signaling has none
    • usesTrickleIce

      public boolean usesTrickleIce()
      Description copied from interface: NetherNetServerSignaling
      Whether this signaling can deliver ICE candidates incrementally after the answer has been sent.
      Specified by:
      usesTrickleIce in interface NetherNetServerSignaling
      Returns:
      true if candidates are trickled as they are gathered
    • allowsIceOnLocalPort

      public boolean allowsIceOnLocalPort()
      Whether ICE may gather on the port signaling is bound to. Set it false when another transport already holds the UDP side of that port, so ICE uses its own.
      Specified by:
      allowsIceOnLocalPort in interface NetherNetServerSignaling
      Returns:
      true if ICE should be pinned to the bound address
    • getIceServers

      public List<NetherNetSignaling.IceServerInfo> getIceServers()
      The STUN and TURN servers ICE may use, which this signaling takes from its configuration rather than from a handshake, since it speaks to nothing that would hand them out.
      Specified by:
      getIceServers in interface NetherNetServerSignaling
    • pendingJoins

      public int pendingJoins()
      How many joins are waiting for an answer, which is what setMaxPendingJoins caps.
      Returns:
      The joins in flight
    • acceptOffer

      public CompletableFuture<String> acceptOffer(String networkId, String sdpOffer, @Nullable InetSocketAddress clientAddress, @Nullable String host)
      Answers an SDP offer, whether it arrived over this server's HTTP endpoint or was handed in from outside it.

      The returned description already carries the ICE candidates and the server identity assertion, so it can be written back to the peer verbatim.

      Parameters:
      networkId - The peer's network ID
      sdpOffer - The raw SDP offer
      clientAddress - The address the offer came from, used for the peer's identity and to seed the child channel, or null if it is not known
      host - The host the peer asked for, passed to the player filter
      Returns:
      The signed SDP answer, or a failure carrying an NetherNetHTTPSignaling.OfferRejected
    • sendFullSdp

      public void sendFullSdp(String targetNetworkId, String sdp)
      Description copied from interface: NetherNetSignaling
      Sends a full SDP message with all candidates to the remote peer TODO Find a better name
      Specified by:
      sendFullSdp in interface NetherNetSignaling
      Parameters:
      targetNetworkId - The Network ID of the destination (String to support Realms).
      sdp - The full SDP message with all candidates.
    • setSignalHandler

      public void setSignalHandler(long connectionId, NetherNetSignaling.SignalHandler handler)
      Description copied from interface: NetherNetSignaling
      Sets a handler to receive signaling messages for a specific connection ID.
      Specified by:
      setSignalHandler in interface NetherNetSignaling
      Parameters:
      connectionId - The connection ID to listen for.
      handler - The handler to process incoming signaling messages.
    • removeSignalHandler

      public void removeSignalHandler(long connectionId)
      Description copied from interface: NetherNetSignaling
      Removes the signaling handler for a specific connection ID.
      Specified by:
      removeSignalHandler in interface NetherNetSignaling
      Parameters:
      connectionId - The connection ID whose handler should be removed.
    • isActive

      public boolean isActive()
      Description copied from interface: NetherNetSignaling
      Whether the signaling is connected and able to carry messages
      Specified by:
      isActive in interface NetherNetSignaling
    • getLocalNetworkId

      public String getLocalNetworkId()
      Description copied from interface: NetherNetSignaling
      Returns the Local Network ID of this client as a String. This is required for formatting the 'candidate:' string in SDP.
      Specified by:
      getLocalNetworkId in interface NetherNetSignaling
    • close

      public void close()
      Description copied from interface: NetherNetSignaling
      Closes the signaling channel and releases any associated resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface NetherNetSignaling