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
  • Field Details

  • Constructor Details

    • AbstractNetherNetXboxSignaling

      protected AbstractNetherNetXboxSignaling(String localNetworkId, String xboxToken, URI uri)
  • Method Details

    • getLocalNetworkId

      public String getLocalNetworkId()
      Description copied from interface: NetherNetSignaling
      Returns 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:
      getLocalNetworkId in interface NetherNetSignaling
    • connect

      public CompletableFuture<List<IceServerInfo>> connect(SocketAddress remoteAddress)
      Description copied from interface: NetherNetClientSignaling
      Connects to the signaling medium (Client mode).
      Specified by:
      connect in interface NetherNetClientSignaling
      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: NetherNetServerSignaling
      Binds the signaling medium to listen for incoming connections (Server mode).
      Specified by:
      bind in interface NetherNetServerSignaling
      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

      protected CompletableFuture<List<IceServerInfo>> connectInternal()
    • userEventTriggered

      public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception
      Specified by:
      userEventTriggered in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      userEventTriggered in class io.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)
      Runs ping on the socket's loop until the socket goes inactive.
    • getIceServers

      public List<IceServerInfo> getIceServers()
      Description copied from interface: NetherNetServerSignaling
      Returns 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 in NetherChannelOption.NETHER_PEER_CONNECTION_CONFIG.
      Specified by:
      getIceServers in interface NetherNetServerSignaling
    • setNewConnectionHandler

      public void setNewConnectionHandler(NetherNetServerSignaling.NewConnectionHandler handler)
      Description copied from interface: NetherNetServerSignaling
      Specified by:
      setNewConnectionHandler in interface NetherNetServerSignaling
      Parameters:
      handler - The handler for new connections
    • setFailureHandler

      public void setFailureHandler(NetherNetClientSignaling.FailureHandler handler)
      Description copied from interface: NetherNetClientSignaling
      Sets 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:
      setFailureHandler in interface NetherNetClientSignaling
      Parameters:
      handler - The handler for signaling failures.
    • setSignalHandler

      public void setSignalHandler(String connectionId, NetherNetSignaling.SignalHandler handler)
      Description copied from interface: NetherNetSignaling
      Sets a handler to receive signaling messages for a specific connection ID.
      Specified by:
      setSignalHandler in interface NetherNetSignaling
      Parameters:
      connectionId - The connection ID to listen for, the token the initiator chose.
      handler - The handler to process incoming signaling messages.
    • removeSignalHandler

      public void removeSignalHandler(String connectionId)
      Description copied from interface: NetherNetSignaling
      Removes the signaling handler for a specific connection ID.
      Specified by:
      removeSignalHandler in interface NetherNetSignaling
      Parameters:
      connectionId - The connection ID whose handler should be removed.
    • reportFailure

      protected void reportFailure(String reason)
      Tells the failure handler, if there is one, that the connection cannot be made.
    • setAdvertisementData

      public void setAdvertisementData(PongData pongData)
      Description copied from interface: NetherNetServerSignaling
      Sets what this host advertises: the LAN pong for discovery, the status document for HTTP signaling, and nothing for signaling that advertises elsewhere.
      Specified by:
      setAdvertisementData in interface NetherNetServerSignaling
      Parameters:
      pongData - The advertisement.
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelHandler
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception
    • isActive

      public boolean isActive()
      Description copied from interface: NetherNetSignaling
      Whether the signaling is connected and able to carry messages
      Specified by:
      isActive in interface NetherNetSignaling
    • close

      public void close()
      Description copied from interface: NetherNetSignaling
      Closes the signaling channel and releases any associated resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface NetherNetSignaling
    • dispatchSignalToPipeline

      protected void dispatchSignalToPipeline(String sender, String rawMsg)
    • parseTurnServers

      protected List<IceServerInfo> parseTurnServers(com.google.gson.JsonObject json)
    • parseTurnServer

      protected @Nullable IceServerInfo parseTurnServer(com.google.gson.JsonElement el)