Class MessageManager
- java.lang.Object
-
- com.biglybt.core.peermanager.messaging.MessageManager
-
public class MessageManager extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static MessageManager
instance
private ByteArrayHashMap
message_map
private java.util.List
messages
protected AEMonitor
this_mon
-
Constructor Summary
Constructors Modifier Constructor Description private
MessageManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Message
createMessage(byte[] id_bytes, DirectByteBuffer message_data, byte version)
Construct a new message instance from the given message information.void
deregisterMessageType(Message message)
Remove registration of given message type from manager.Message[]
getRegisteredMessages()
Get a list of the registered messages.static MessageManager
getSingleton()
void
initialize()
Perform manager initialization.Message
lookupMessage(byte[] id_bytes)
Message
lookupMessage(java.lang.String id)
Lookup a registered message type via id and version.void
registerMessageType(Message message)
Register the given message type with the manager for processing.
-
-
-
Field Detail
-
instance
private static final MessageManager instance
-
message_map
private final ByteArrayHashMap message_map
-
messages
private final java.util.List messages
-
this_mon
protected final AEMonitor this_mon
-
-
Method Detail
-
getSingleton
public static MessageManager getSingleton()
-
initialize
public void initialize()
Perform manager initialization.
-
registerMessageType
public void registerMessageType(Message message) throws MessageException
Register the given message type with the manager for processing.- Parameters:
message
- instance to use for decoding- Throws:
MessageException
- if this message type has already been registered
-
deregisterMessageType
public void deregisterMessageType(Message message)
Remove registration of given message type from manager.- Parameters:
message
- type to remove
-
createMessage
public Message createMessage(byte[] id_bytes, DirectByteBuffer message_data, byte version) throws MessageException
Construct a new message instance from the given message information.- Parameters:
id
- of messagemessage_data
- payload- Returns:
- decoded/deserialized message
- Throws:
MessageException
- if message creation failed
-
lookupMessage
public Message lookupMessage(java.lang.String id)
Lookup a registered message type via id and version.- Parameters:
id
- to look for- Returns:
- the default registered message instance if found, otherwise returns null if this message type is not registered
-
lookupMessage
public Message lookupMessage(byte[] id_bytes)
-
getRegisteredMessages
public Message[] getRegisteredMessages()
Get a list of the registered messages.- Returns:
- messages
-
-