Interface RawPlayDataChannel
-
public interface RawPlayDataChannel
Represents a channel that sends and receives raw data. This channel cannot be used during the handshake phase of aEngineConnection
, useRawHandshakeDataChannel
instead.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <C extends EngineConnection>
voidaddHandler(java.lang.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
.RawDataChannel
parent()
Gets the parentRawDataChannel
.<C extends EngineConnection>
voidremoveHandler(java.lang.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 java.util.concurrent.CompletableFuture<java.lang.Void>
sendTo(ServerPlayer player, java.util.function.Consumer<ChannelBuf> payload)
Sends the raw payload to the player across this channel.java.util.concurrent.CompletableFuture<java.lang.Void>
sendTo(EngineConnection connection, java.util.function.Consumer<ChannelBuf> payload)
Sends the raw payload to the player across this channel.default void
sendToAllPlayers(java.util.function.Consumer<ChannelBuf> payload)
Sends the raw payload to all players on the server.default void
sendToAllPlayersIn(ServerWorld world, java.util.function.Consumer<ChannelBuf> payload)
Sends thePacket
to all players in the given world.default java.util.concurrent.CompletableFuture<java.lang.Void>
sendToServer(java.util.function.Consumer<ChannelBuf> payload)
Sends the raw payload to the server.
-
-
-
Method Detail
-
parent
RawDataChannel parent()
Gets the parentRawDataChannel
.- Returns:
- The raw data channel
-
isSupportedBy
boolean isSupportedBy(EngineConnection connection)
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
void addHandler(RawPlayDataHandler<EngineConnection> 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
<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(java.lang.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(java.lang.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
void removeHandler(RawPlayDataHandler<?> handler)
Removes the handler from handling data.- Parameters:
handler
- The handler
-
sendToAllPlayers
default void sendToAllPlayers(java.util.function.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, java.util.function.Consumer<ChannelBuf> payload)
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
default java.util.concurrent.CompletableFuture<java.lang.Void> sendTo(ServerPlayer player, java.util.function.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 topayload
- A consumer to write the data to- Returns:
- A future which will complete when the operation has finished
-
sendToServer
default java.util.concurrent.CompletableFuture<java.lang.Void> sendToServer(java.util.function.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
java.util.concurrent.CompletableFuture<java.lang.Void> sendTo(EngineConnection connection, java.util.function.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 topayload
- A consumer to write the data to- Returns:
- A future which will complete when the operation has finished
-
-