Interface RawPlayDataChannel


public interface RawPlayDataChannel
Represents a channel that sends and receives raw data. This channel cannot be used during the handshake phase of a EngineConnection, use RawHandshakeDataChannel instead.
  • Method Details

    • parent

      RawDataChannel parent()
      Gets the parent RawDataChannel.
      Returns:
      The raw data channel
    • isSupportedBy

      boolean isSupportedBy(EngineConnection connection)
      Gets whether the data channel this sub-channel belongs to is supported by the given EngineConnection.

      A data channel is supported if the other side of the connection also supports the channel.

      Parameters:
      connection - The connection to check
      Returns:
      Whether the packet channel is supported
    • addHandler

      void addHandler(RawPlayDataHandler<EngineConnectionState> handler)
      Adds a handler to this channel that is invoked every time data is sent to it on either side.
      Parameters:
      handler - The handler
    • addHandler

      <S extends EngineConnectionState> void addHandler(Class<S> connectionState, RawPlayDataHandler<? super S> handler)
      Adds a listener to this channel that is invoked every time data is sent to it on the given connection side.
      Type Parameters:
      S - The connection state
      Parameters:
      connectionState - The connection state the data will be handled for
      handler - The handler
    • removeHandler

      <S extends EngineConnectionState> void removeHandler(Class<S> connectionState, RawPlayDataHandler<? super S> handler)
      Removes the handler from handling data.
      Type Parameters:
      S - The connection state
      Parameters:
      connectionState - The connection state to remove the handler from
      handler - The handler
    • removeHandler

      void removeHandler(RawPlayDataHandler<?> handler)
      Removes the handler from handling data.
      Parameters:
      handler - The handler
    • sendToAllPlayers

      default void sendToAllPlayers(Consumer<ChannelBuf> payload)
      Sends the raw payload to all players on the server.
      Parameters:
      payload - A consumer to write the data to
    • sendToAllPlayersIn

      default void sendToAllPlayersIn(ServerWorld world, Consumer<ChannelBuf> payload)
      Sends the Packet to all players in the given world.

      A exception will be thrown if the specified packet type isn't registered in the PacketChannel this dispatcher belongs to.

      Parameters:
      world - The world
      payload - A consumer to write the data to
    • sendTo

      default CompletableFuture<Void> sendTo(ServerPlayer player, Consumer<ChannelBuf> payload)
      Sends the raw payload to the player across this channel. The data may not be sent if the player doesn't have a registered handler.
      Parameters:
      player - The player to send the message to
      payload - A consumer to write the data to
      Returns:
      A future which will complete when the operation has finished
    • sendToServer

      default CompletableFuture<Void> sendToServer(Consumer<ChannelBuf> payload)
      Sends the raw payload to the server. The data may not be sent if there is no registered handler. This must be called from the client side.
      Parameters:
      payload - A consumer to write the data to
      Returns:
      A future which will complete when the operation has finished
    • sendTo

      CompletableFuture<Void> sendTo(EngineConnection connection, Consumer<ChannelBuf> payload)
      Sends the raw payload to the player across this channel. The data may not be sent if the player doesn't have a registered handler.
      Parameters:
      connection - The client connection to send the message to
      payload - A consumer to write the data to
      Returns:
      A future which will complete when the operation has finished