Class NetherNetDiscoverySignaling
java.lang.Object
org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetDiscoverySignaling
- All Implemented Interfaces:
AutoCloseable,NetherNetClientSignaling,NetherNetServerSignaling,NetherNetSignaling
public class NetherNetDiscoverySignaling
extends Object
implements NetherNetClientSignaling, NetherNetServerSignaling
-
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.NetherNetServerSignaling
NetherNetServerSignaling.NewConnectionHandlerNested classes/interfaces inherited from interface org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetSignaling
NetherNetSignaling.SignalHandler -
Constructor Summary
ConstructorsConstructorDescriptionCreates a NetherNetDiscoverySignaling with a random local Network ID and binds to an ephemeral port.NetherNetDiscoverySignaling(long localNetworkId) Creates a NetherNetDiscoverySignaling with the specified local Network ID.NetherNetDiscoverySignaling(long localNetworkId, InetSocketAddress bindAddress) Creates a NetherNetDiscoverySignaling with the specified local Network ID and bind address. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether ICE may bind to the address the channel was bound to, instead of an ephemeral port.voidbind(SocketAddress localAddress, @Nullable InetSocketAddress iceAddress, io.netty.channel.EventLoop eventLoop) Binds the signaling medium to listen for incoming connections (Server mode).voidclose()Closes the signaling channel and releases any associated resources.connect(SocketAddress remote) 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 messagesvoidremoveSignalHandler(String connectionId) Removes the signaling handler for a specific connection ID.voidsendSignal(String targetNetworkId, String data) Sends a signaling message to the remote peer.@Nullable OperatorIdentityReturns the identity used to sign SDP answers, or null to have each server channel generate one of its own under the domainself, which is then what players see in the trust prompt and which changes on every start.voidsetAdvertisementData(PongData pongData) Sets what this host advertises: the LAN pong for discovery, the status document for HTTP signaling, and nothing for signaling that advertises elsewhere.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.voidsetMotdProvider(MotdProvider provider) Asksproviderfor the LAN pong on every discovery request, seeNetherNetDiscovery.setMotdProvider(org.cloudburstmc.netty.channel.nethernet.signaling.MotdProvider).voidSets the handler a new connection is handed to, seeNetherNetServerSignaling.NewConnectionHandler.onConnect(java.lang.String, java.lang.String, java.lang.String, java.net.InetSocketAddress, org.cloudburstmc.netty.util.nethernet.PlayerInfo).voidsetServerIdentity(@Nullable OperatorIdentity identity) Sets the identity answers are signed with, which the server channel reads when it is created.voidsetSignalHandler(String connectionId, NetherNetSignaling.SignalHandler handler) Sets a handler to receive signaling messages for a specific connection ID.voidsetTokenTrust(TokenTrust tokenTrust) Sets who must have signed the token in a join's identity assertion,TokenTrust.MINECRAFT_AUTHunless set.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.NetherNetServerSignaling
getIceServers, setMetricsMethods inherited from interface org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetSignaling
sendDescription, usesTrickleIce
-
Constructor Details
-
NetherNetDiscoverySignaling
public NetherNetDiscoverySignaling()Creates a NetherNetDiscoverySignaling with a random local Network ID and binds to an ephemeral port. -
NetherNetDiscoverySignaling
public NetherNetDiscoverySignaling(long localNetworkId) Creates a NetherNetDiscoverySignaling with the specified local Network ID.- Parameters:
localNetworkId- The local Network ID to use.
-
NetherNetDiscoverySignaling
Creates a NetherNetDiscoverySignaling with the specified local Network ID and bind address.- Parameters:
localNetworkId- The local Network ID to use.bindAddress- The address to bind the discovery socket to.
-
-
Method Details
-
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
-
connect
Description copied from interface:NetherNetClientSignalingConnects to the signaling medium (Client mode).- Specified by:
connectin interfaceNetherNetClientSignaling- Parameters:
remote- The address of the signaling server to connect to.
-
allowsIceOnLocalPort
public boolean allowsIceOnLocalPort()Description copied from interface:NetherNetServerSignalingWhether ICE may bind to the address the channel was bound to, instead of an ephemeral port.- Specified by:
allowsIceOnLocalPortin interfaceNetherNetServerSignaling- Returns:
- true if ICE should be pinned to the bound address
-
bind
public void bind(SocketAddress localAddress, @Nullable InetSocketAddress iceAddress, io.netty.channel.EventLoop eventLoop) Description copied from interface:NetherNetServerSignalingBinds the signaling medium to listen for incoming connections (Server mode).- Specified by:
bindin interfaceNetherNetServerSignaling- Parameters:
localAddress- The local address to bind to.iceAddress- Where ICE binds, on a fixed port shared by every connection, or null when each connection takes a port of its own. A wildcard address gathers on every interface.eventLoop- The owning channel's event loop, where new connections are handed over.
-
setTokenTrust
Sets who must have signed the token in a join's identity assertion,TokenTrust.MINECRAFT_AUTHunless set. A join whose assertion does not hold is dropped. One without an assertion is handed over without a player, leaving whether to admit it to the host. -
setServerIdentity
Sets the identity answers are signed with, which the server channel reads when it is created. Without one each channel makes its own, seeNetherNetServerSignaling.serverIdentity(). -
serverIdentity
Description copied from interface:NetherNetServerSignalingReturns the identity used to sign SDP answers, or null to have each server channel generate one of its own under the domainself, which is then what players see in the trust prompt and which changes on every start.- Specified by:
serverIdentityin interfaceNetherNetServerSignaling- Returns:
- The server identity, or null if this signaling has none
-
setNewConnectionHandler
Description copied from interface:NetherNetServerSignalingSets the handler a new connection is handed to, seeNetherNetServerSignaling.NewConnectionHandler.onConnect(java.lang.String, java.lang.String, java.lang.String, java.net.InetSocketAddress, org.cloudburstmc.netty.util.nethernet.PlayerInfo). The server channel installs its own on bind.- Specified by:
setNewConnectionHandlerin interfaceNetherNetServerSignaling- Parameters:
handler- The handler for new connections
-
setAdvertisementData
Description copied from interface:NetherNetServerSignalingSets what this host advertises: the LAN pong for discovery, the status document for HTTP signaling, and nothing for signaling that advertises elsewhere.- Specified by:
setAdvertisementDatain interfaceNetherNetServerSignaling- Parameters:
pongData- The advertisement.
-
setMotdProvider
Asksproviderfor the LAN pong on every discovery request, seeNetherNetDiscovery.setMotdProvider(org.cloudburstmc.netty.channel.nethernet.signaling.MotdProvider). -
sendSignal
Description copied from interface:NetherNetSignalingSends a signaling message to the remote peer. Required whenNetherNetSignaling.usesTrickleIce()is true, which is the default.- Specified by:
sendSignalin interfaceNetherNetSignaling- Parameters:
targetNetworkId- The Network ID of the destination (String to support Realms).data- The raw signaling payload.
-
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.
-
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
-