Class AbstractNetherNetXboxSignaling
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.TextWebSocketFrame>
org.cloudburstmc.netty.channel.nethernet.signaling.AbstractNetherNetXboxSignaling
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,AutoCloseable,NetherNetClientSignaling,NetherNetServerSignaling,NetherNetSignaling
- Direct Known Subclasses:
NetherNetXboxRpcSignaling,NetherNetXboxSignaling
public abstract class AbstractNetherNetXboxSignaling
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.TextWebSocketFrame>
implements NetherNetClientSignaling, NetherNetServerSignaling
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.SharableNested 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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected io.netty.channel.Channelprotected CompletableFuture<List<IceServerInfo>>protected final io.netty.channel.EventLoopGroupprotected NetherNetClientSignaling.FailureHandlerprotected final Map<String,NetherNetSignaling.SignalHandler> protected List<IceServerInfo>protected final Stringprotected final io.netty.util.internal.logging.InternalLoggerprotected final URIprotected final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNetherNetXboxSignaling(String localNetworkId, String xboxToken, URI uri) -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(SocketAddress localAddress, @Nullable InetSocketAddress iceAddress, io.netty.channel.EventLoop eventLoop) Binds the signaling medium to listen for incoming connections (Server mode).voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voidclose()Closes the signaling channel and releases any associated resources.connect(SocketAddress remoteAddress) Connects to the signaling medium (Client mode).protected CompletableFuture<List<IceServerInfo>>protected voiddispatchSignalToPipeline(String sender, String rawMsg) voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) Returns the ICE servers (STUN/TURN) obtained from the signaling handshake, which every connection gathers through.Returns the Local Network ID this side is addressed by.booleanisActive()Whether the signaling is connected and able to carry messagesprotected voidkeepAlive(io.netty.channel.ChannelHandlerContext ctx, long initialSeconds, long periodSeconds, Runnable ping) Runspingon the socket's loop until the socket goes inactive.protected abstract voidonConnected(io.netty.channel.ChannelHandlerContext ctx) Called when the WebSocket handshake is complete.protected @Nullable IceServerInfoparseTurnServer(com.google.gson.JsonElement el) protected List<IceServerInfo>parseTurnServers(com.google.gson.JsonObject json) voidremoveSignalHandler(String connectionId) Removes the signaling handler for a specific connection ID.protected voidreportFailure(String reason) Tells the failure handler, if there is one, that the connection cannot be made.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.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).voidsetSignalHandler(String connectionId, NetherNetSignaling.SignalHandler handler) Sets a handler to receive signaling messages for a specific connection ID.voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead, channelRead0Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChangedMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemovedMethods inherited from interface org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetServerSignaling
allowsIceOnLocalPort, serverIdentity, setMetricsMethods inherited from interface org.cloudburstmc.netty.channel.nethernet.signaling.NetherNetSignaling
sendDescription, sendSignal, usesTrickleIce
-
Field Details
-
log
protected final io.netty.util.internal.logging.InternalLogger log -
xboxToken
-
localNetworkId
-
uri
-
eventLoopGroup
protected final io.netty.channel.EventLoopGroup eventLoopGroup -
channel
protected io.netty.channel.Channel channel -
connectFuture
-
iceServers
-
handlers
-
newConnectionHandler
-
failureHandler
-
-
Constructor Details
-
AbstractNetherNetXboxSignaling
-
-
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:
remoteAddress- The address of the signaling server to connect to.
-
bind
public void bind(SocketAddress localAddress, @Nullable InetSocketAddress iceAddress, 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.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.- Throws:
ConnectException- If the signaling cannot bind
-
connectInternal
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception - Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
onConnected
protected abstract void onConnected(io.netty.channel.ChannelHandlerContext ctx) Called when the WebSocket handshake is complete. -
keepAlive
protected void keepAlive(io.netty.channel.ChannelHandlerContext ctx, long initialSeconds, long periodSeconds, Runnable ping) Runspingon the socket's loop until the socket goes inactive. -
getIceServers
Description copied from interface:NetherNetServerSignalingReturns the ICE servers (STUN/TURN) obtained from the signaling handshake, which every connection gathers through. Returns empty list if none available or not applicable. Servers of the host's own go inNetherChannelOption.NETHER_PEER_CONNECTION_CONFIG.- Specified by:
getIceServersin interfaceNetherNetServerSignaling
-
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
-
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.
-
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.
-
reportFailure
Tells the failure handler, if there is one, that the connection cannot be made. -
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.
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
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
-
dispatchSignalToPipeline
-
parseTurnServers
-
parseTurnServer
-