Class NetherNetHTTPClientSignaling
- All Implemented Interfaces:
AutoCloseable,NetherNetClientSignaling,NetherNetSignaling
/v1/join endpoint, as a
proxy does toward a downstream server. One instance serves one connection.
HTTP signaling is a single request and response, so there is no trickle: the channel gathers
every candidate first and hands the finished offer to sendDescription(java.lang.String, java.lang.String), and the answer
comes back through the signal handler like any other. The offer's identity assertion is the
channel's business too, through NetherChannelOption.NETHER_CLIENT_IDENTITY.
By default it does what the retail client does: probes the endpoint over HTTPS, falls back to
plaintext when there is no TLS, and posts the offer over whichever answered. HTTPS validates the
certificate against the JDK trust store, or the one in the settings, and the host name of the
address it was given, so a server behind a certificate has to be addressed by name. A server
serving TLS refuses plaintext by default. HttpSignalingSettings fixes the scheme instead.
Nothing here runs on the channel's loop, the channel moves itself back onto it.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat a probe found: the scheme that answered and the status the server advertises.Nested classes/interfaces inherited from interface org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetClientSignaling
NetherNetClientSignaling.FailureHandlerNested classes/interfaces inherited from interface org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetSignaling
NetherNetSignaling.SignalHandler -
Constructor Summary
ConstructorsConstructorDescriptionSignals asHttpSignalingSettings.DEFAULTsays, with a random network id.Signals as the settings say, with a random network id.NetherNetHTTPClientSignaling(HttpSignalingSettings settings, String localNetworkId) Signals as the settings say, with the given network id. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the signaling channel and releases any associated resources.connect(SocketAddress remoteAddress) Connects to the signaling medium (Client mode).Returns the Local Network ID this side is addressed by.booleanisActive()Whether the signaling is connected and able to carry messagesprobe(InetSocketAddress address, HttpSignalingSettings settings) Asprobe(InetSocketAddress, HttpSignalingSettings, String), sending no network id.probe(InetSocketAddress address, HttpSignalingSettings settings, @Nullable String networkId) Asks the endpoint whether it serves NetherNet, the way the settings say, which forHttpSignalingSettings.Scheme.AUTOis HTTPS first and plaintext when the host answered without TLS.voidremoveSignalHandler(String connectionId) Removes the signaling handler for a specific connection ID.voidsendDescription(String targetNetworkId, String offer) Sends a complete session description, every gathered candidate included, to the remote peer.voidSets a handler to be called when the signaling cannot deliver the connection: the target is not found or offline, or an endpoint refused the offer.voidsetSignalHandler(String connectionId, NetherNetSignaling.SignalHandler handler) Sets a handler to receive signaling messages for a specific connection ID.booleanWhether this signaling delivers ICE candidates one by one as they are gathered.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetSignaling
sendSignal
-
Constructor Details
-
NetherNetHTTPClientSignaling
public NetherNetHTTPClientSignaling()Signals asHttpSignalingSettings.DEFAULTsays, with a random network id. -
NetherNetHTTPClientSignaling
Signals as the settings say, with a random network id. -
NetherNetHTTPClientSignaling
Signals as the settings say, with the given network id.
-
-
Method Details
-
probe
public static CompletableFuture<NetherNetHTTPClientSignaling.Probe> probe(InetSocketAddress address, HttpSignalingSettings settings) Asprobe(InetSocketAddress, HttpSignalingSettings, String), sending no network id. -
probe
public static CompletableFuture<NetherNetHTTPClientSignaling.Probe> probe(InetSocketAddress address, HttpSignalingSettings settings, @Nullable String networkId) Asks the endpoint whether it serves NetherNet, the way the settings say, which forHttpSignalingSettings.Scheme.AUTOis HTTPS first and plaintext when the host answered without TLS. A host that does not answer fails at once. A server that does not serve NetherNet answers 404, which fails the probe and is what drives a fallback to RakNet.- Parameters:
address- The server's signaling endpointsettings- How to reach itnetworkId- The network id the client will join as, or null to send none- Returns:
- The scheme that answered and the server's status, or a failure saying why not
-
usesTrickleIce
public boolean usesTrickleIce()Description copied from interface:NetherNetSignalingWhether this signaling delivers ICE candidates one by one as they are gathered. Signaling that cannot, such as a single HTTP exchange, receives oneNetherNetSignaling.sendDescription(java.lang.String, java.lang.String)once gathering is complete and no candidate signals at all.- Specified by:
usesTrickleIcein interfaceNetherNetSignaling- Returns:
- true if candidates are trickled as they are gathered
-
connect
Description copied from interface:NetherNetClientSignalingConnects to the signaling medium (Client mode).- Specified by:
connectin interfaceNetherNetClientSignaling- Parameters:
remoteAddress- The address of the signaling server to connect to.
-
sendDescription
Description copied from interface:NetherNetSignalingSends a complete session description, every gathered candidate included, to the remote peer. This is how a description travels whenNetherNetSignaling.usesTrickleIce()is false, on either side.- Specified by:
sendDescriptionin interfaceNetherNetSignaling- Parameters:
targetNetworkId- The Network ID of the destination (String to support Realms).offer- The complete description.
-
setSignalHandler
Description copied from interface:NetherNetSignalingSets a handler to receive signaling messages for a specific connection ID.- Specified by:
setSignalHandlerin interfaceNetherNetSignaling- Parameters:
connectionId- The connection ID to listen for, the token the initiator chose.handler- The handler to process incoming signaling messages.
-
removeSignalHandler
Description copied from interface:NetherNetSignalingRemoves the signaling handler for a specific connection ID.- Specified by:
removeSignalHandlerin interfaceNetherNetSignaling- Parameters:
connectionId- The connection ID whose handler should be removed.
-
setFailureHandler
Description copied from interface:NetherNetClientSignalingSets a handler to be called when the signaling cannot deliver the connection: the target is not found or offline, or an endpoint refused the offer.- Specified by:
setFailureHandlerin interfaceNetherNetClientSignaling- Parameters:
handler- The handler for signaling failures.
-
getLocalNetworkId
Description copied from interface:NetherNetSignalingReturns the Local Network ID this side is addressed by. A client puts it in its join, a server that is addressed by host name rather than network id, such as HTTP signaling, returns an empty string.- Specified by:
getLocalNetworkIdin interfaceNetherNetSignaling
-
isActive
public boolean isActive()Description copied from interface:NetherNetSignalingWhether the signaling is connected and able to carry messages- Specified by:
isActivein interfaceNetherNetSignaling
-
close
public void close()Description copied from interface:NetherNetSignalingCloses the signaling channel and releases any associated resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceNetherNetSignaling
-