public static interface ChannelBinding.IndexedMessageChannel extends ChannelBinding
ChannelBinding.IndexedMessageChannel, ChannelBinding.RawDataChannel
Modifier and Type | Method and Description |
---|---|
<M extends Message> |
addHandler(Class<M> messageClass,
MessageHandler<M> handler)
Register a
MessageHandler for a Message |
<M extends Message> |
addHandler(Class<M> messageClass,
Platform.Type side,
MessageHandler<M> handler)
Register a
MessageHandler for a Message . |
void |
registerMessage(Class<? extends Message> messageClass,
int messageId)
Register a message class to this channel without a receiving handler.
|
<M extends Message> |
registerMessage(Class<M> messageClass,
int messageId,
MessageHandler<M> handler)
Register a message class to this channel and a handler for receiving
the message.
|
<M extends Message> |
registerMessage(Class<M> messageClass,
int messageId,
Platform.Type side,
MessageHandler<M> handler)
Register a message class to this channel and a handler for receiving
the message.
|
void |
sendTo(Player player,
Message message)
Sends the message to the player across this channel.
|
void |
sendToAll(Message message)
Sends the message to all players on the server.
|
void |
sendToServer(Message message)
Sends the message to the server.
|
getName, getOwner, getRegistrar
void registerMessage(Class<? extends Message> messageClass, int messageId)
The message ID is used to identify this message class as it is sent and received across the network, it is a single byte and thus has a range of 0 to 255.
messageClass
- The class of the message being registered. Note:
the class must have a publicly accessible no-args constructormessageId
- A unique ID for this message<M extends Message> void registerMessage(Class<M> messageClass, int messageId, MessageHandler<M> handler)
messageClass
- The class of the message being registeredmessageId
- A unique ID for this messagehandler
- The handler that acts upon the message being received<M extends Message> void registerMessage(Class<M> messageClass, int messageId, Platform.Type side, MessageHandler<M> handler)
messageClass
- The class of the message being registeredmessageId
- A unique ID for this messageside
- The side to listen to messages onhandler
- The handler that acts upon the message being received<M extends Message> void addHandler(Class<M> messageClass, Platform.Type side, MessageHandler<M> handler)
MessageHandler
for a Message
.M
- The type of messagemessageClass
- The class to handleside
- The side being handledhandler
- The handler<M extends Message> void addHandler(Class<M> messageClass, MessageHandler<M> handler)
MessageHandler
for a Message
M
- The type of messagemessageClass
- The class to handlehandler
- The handlervoid sendTo(Player player, Message message)
player
- The player to send the message tomessage
- The message to sendvoid sendToServer(Message message)
message
- The message to sendvoid sendToAll(Message message)
message
- The message to send