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 Summary
Modifier and TypeMethodDescription<C extends EngineConnection>
voidaddHandler
(Class<C> connectionType, RawPlayDataHandler<? super C> handler) Adds a listener to this channel that is invoked every time data is sent to it on the given connection side.void
addHandler
(RawPlayDataHandler<EngineConnection> handler) Adds a handler to this channel that is invoked every time data is sent to it on either side.<C extends EngineConnection>
voidaddHandler
(EngineConnectionSide<C> side, RawPlayDataHandler<? super C> handler) Adds a listener to this channel that is invoked every time data is sent to it on the given connection side.boolean
isSupportedBy
(EngineConnection connection) Gets whether the data channel this sub-channel belongs to is supported by the givenEngineConnection
.parent()
Gets the parentRawDataChannel
.<C extends EngineConnection>
voidremoveHandler
(Class<C> connectionType, RawPlayDataHandler<? super C> handler) Removes the handler from handling data.void
removeHandler
(RawPlayDataHandler<?> handler) Removes the handler from handling data.<C extends EngineConnection>
voidremoveHandler
(EngineConnectionSide<C> side, RawPlayDataHandler<? super C> handler) Removes the handler from handling data.default CompletableFuture<Void>
sendTo
(ServerPlayer player, Consumer<ChannelBuf> payload) Sends the raw payload to the player across this channel.sendTo
(EngineConnection connection, Consumer<ChannelBuf> payload) Sends the raw payload to the player across this channel.default void
sendToAllPlayers
(Consumer<ChannelBuf> payload) Sends the raw payload to all players on the server.default void
sendToAllPlayersIn
(ServerWorld world, Consumer<ChannelBuf> payload) Sends thePacket
to all players in the given world.default CompletableFuture<Void>
sendToServer
(Consumer<ChannelBuf> payload) Sends the raw payload to the server.
-
Method Details
-
parent
RawDataChannel parent()Gets the parentRawDataChannel
.- Returns:
- The raw data channel
-
isSupportedBy
Gets whether the data channel this sub-channel belongs to is supported by the givenEngineConnection
.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
Adds a handler to this channel that is invoked every time data is sent to it on either side.- Parameters:
handler
- The handler
-
addHandler
<C extends EngineConnection> void addHandler(EngineConnectionSide<C> side, RawPlayDataHandler<? super C> handler) Adds a listener to this channel that is invoked every time data is sent to it on the given connection side.- Type Parameters:
C
- The connection type- Parameters:
side
- The connection side the data will be handled forhandler
- The handler
-
addHandler
<C extends EngineConnection> void addHandler(Class<C> connectionType, RawPlayDataHandler<? super C> handler) Adds a listener to this channel that is invoked every time data is sent to it on the given connection side.- Type Parameters:
C
- The connection type- Parameters:
connectionType
- The connection type the data will be handled forhandler
- The handler
-
removeHandler
<C extends EngineConnection> void removeHandler(EngineConnectionSide<C> side, RawPlayDataHandler<? super C> handler) Removes the handler from handling data.- Type Parameters:
C
- The connection type- Parameters:
side
- The side to remove the handler fromhandler
- The handler
-
removeHandler
<C extends EngineConnection> void removeHandler(Class<C> connectionType, RawPlayDataHandler<? super C> handler) Removes the handler from handling data.- Type Parameters:
C
- The connection type- Parameters:
connectionType
- The connection type to remove the handler fromhandler
- The handler
-
removeHandler
Removes the handler from handling data.- Parameters:
handler
- The handler
-
sendToAllPlayers
Sends the raw payload to all players on the server.- Parameters:
payload
- A consumer to write the data to
-
sendToAllPlayersIn
Sends thePacket
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 worldpayload
- A consumer to write the data to
-
sendTo
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 topayload
- A consumer to write the data to- Returns:
- A future which will complete when the operation has finished
-
sendToServer
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
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 topayload
- A consumer to write the data to- Returns:
- A future which will complete when the operation has finished
-