Class NetherNetHTTPSignaling
java.lang.Object
org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetHTTPSignaling
- All Implemented Interfaces:
AutoCloseable,NetherNetServerSignaling,NetherNetSignaling
This class implements a signaling server using HTTP(S) for the NetherNet protocol.
Follows ...
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder forNetherNetHTTPSignaling.static interfaceFunctional interface providing the MOTD returned to clients querying the server.static final classWhy an offer did not produce an answer.static interfaceFunctional interface for filtering players before a connection is created for them.Nested classes/interfaces inherited from interface org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetServerSignaling
NetherNetServerSignaling.NewConnectionHandler, NetherNetServerSignaling.PongDataNested classes/interfaces inherited from interface org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetSignaling
NetherNetSignaling.IceServerInfo, NetherNetSignaling.SignalHandler -
Method Summary
Modifier and TypeMethodDescriptionacceptOffer(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.booleanWhether ICE may gather on the port signalling is bound to.voidbind(SocketAddress localAddress, 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.The STUN and TURN servers ICE may use, which this signalling takes from its configuration rather than from a handshake, since it speaks to nothing that would hand them out.Returns the Local Network ID of this client as a String.booleanisActive()Whether the signaling is connected and able to carry messagesvoidremoveSignalHandler(long connectionId) Removes the signaling handler for a specific connection ID.voidsendFullSdp(String targetNetworkId, String sdp) Sends a full SDP message with all candidates to the remote peer TODO Find a better nameReturns the identity used to sign SDP answers, or null to have the channel generate an ephemeral one.voidSets the advertisement data for the discovery mechanism (e.g.voidHandler for new connections.voidsetSignalHandler(long connectionId, NetherNetSignaling.SignalHandler handler) Sets a handler to receive signaling messages for a specific connection ID.booleanWhether this signaling can deliver ICE candidates incrementally after the answer has been sent.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
-
Method Details
-
bind
public void bind(SocketAddress localAddress, io.netty.channel.EventLoop eventLoop) throws ConnectException 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.eventLoop- The owning channel's event loop.- Throws:
ConnectException
-
setNewConnectionHandler
Description copied from interface:NetherNetServerSignalingHandler for new connections.- Specified by:
setNewConnectionHandlerin interfaceNetherNetServerSignaling- Parameters:
handler- Functional interface receiving (ConnectionID, RemoteNetworkID, Payload)
-
setAdvertisementData
Description copied from interface:NetherNetServerSignalingSets the advertisement data for the discovery mechanism (e.g. LAN Pong).- Specified by:
setAdvertisementDatain interfaceNetherNetServerSignaling- Parameters:
pongData- The Pong advertisement data.
-
serverIdentity
Description copied from interface:NetherNetServerSignalingReturns the identity used to sign SDP answers, or null to have the channel generate an ephemeral one.- Specified by:
serverIdentityin interfaceNetherNetServerSignaling- Returns:
- The server identity, or null if this signaling has none
-
usesTrickleIce
public boolean usesTrickleIce()Description copied from interface:NetherNetServerSignalingWhether this signaling can deliver ICE candidates incrementally after the answer has been sent.- Specified by:
usesTrickleIcein interfaceNetherNetServerSignaling- Returns:
- true if candidates are trickled as they are gathered
-
allowsIceOnLocalPort
public boolean allowsIceOnLocalPort()Whether ICE may gather on the port signalling is bound to. Set it false when another transport already holds the UDP side of that port, so ICE uses its own.- Specified by:
allowsIceOnLocalPortin interfaceNetherNetServerSignaling- Returns:
- true if ICE should be pinned to the bound address
-
getIceServers
The STUN and TURN servers ICE may use, which this signalling takes from its configuration rather than from a handshake, since it speaks to nothing that would hand them out.- Specified by:
getIceServersin interfaceNetherNetServerSignaling
-
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 IDsdpOffer- The raw SDP offerclientAddress- The address the offer came from, used for the peer's identity and to seed the child channel, or null if it is not knownhost- The host the peer asked for, passed to the player filter- Returns:
- The signed SDP answer, or a failure carrying an
NetherNetHTTPSignaling.OfferRejected
-
sendFullSdp
Description copied from interface:NetherNetSignalingSends a full SDP message with all candidates to the remote peer TODO Find a better name- Specified by:
sendFullSdpin interfaceNetherNetSignaling- Parameters:
targetNetworkId- The Network ID of the destination (String to support Realms).sdp- The full SDP message with all candidates.
-
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.handler- The handler to process incoming signaling messages.
-
removeSignalHandler
public void removeSignalHandler(long connectionId) 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.
-
isActive
public boolean isActive()Description copied from interface:NetherNetSignalingWhether the signaling is connected and able to carry messages- Specified by:
isActivein interfaceNetherNetSignaling
-
getLocalNetworkId
Description copied from interface:NetherNetSignalingReturns the Local Network ID of this client as a String. This is required for formatting the 'candidate:' string in SDP.- Specified by:
getLocalNetworkIdin 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
-