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.
Plaintext by default. With secure it speaks HTTPS instead, validating the certificate
against the JDK trust store and the host name of the address it was given, so a server behind
a real certificate has to be addressed by name. The two have to agree with the server: one
that serves TLS refuses plaintext by default, and one that does not cannot be reached securely.
Nothing here runs on the channel's loop, the channel moves itself back onto it.
-
Nested Class Summary
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
ConstructorsConstructorDescriptionWithout STUN or TURN, so the offer carries the local interfaces only and goes out as soon as they are gathered.NetherNetHTTPClientSignaling(List<IceServerInfo> iceServers) NetherNetHTTPClientSignaling(List<IceServerInfo> iceServers, boolean secure) -
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 messagesstatic CompletableFuture<Boolean>probe(InetSocketAddress address) The plaintext capability probe, seeprobe(InetSocketAddress, boolean).static CompletableFuture<Boolean>probe(InetSocketAddress address, boolean secure) The capability probe.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()Without STUN or TURN, so the offer carries the local interfaces only and goes out as soon as they are gathered. -
NetherNetHTTPClientSignaling
- Parameters:
iceServers- The STUN and TURN servers to gather through. Every one of them has to answer or time out before the offer can go, since nothing trickles after it.
-
NetherNetHTTPClientSignaling
- Parameters:
iceServers- The STUN and TURN servers to gather through, see abovesecure- Whether to signal over HTTPS rather than plaintext HTTP
-
-
Method Details
-
probe
The plaintext capability probe, seeprobe(InetSocketAddress, boolean). -
probe
The capability probe. A non 2xx here is how a server says it does not speak NetherNet, which is what drives a fallback to RakNet. A server that requires TLS answers a plaintext probe with 426, so that counts as unreachable too unless the probe is secure.- Parameters:
address- The server's signaling endpointsecure- Whether to probe over HTTPS- Returns:
- Whether the endpoint answered as a NetherNet server
-
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
-