Class BTMessageFactory
- java.lang.Object
-
- com.biglybt.core.peermanager.messaging.bittorrent.BTMessageFactory
-
public class BTMessageFactory extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
BTMessageFactory.LegacyData
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]
id_to_name
private static java.util.HashMap
legacy_data
private static LogIDs
LOGID
static byte
MESSAGE_VERSION_INITIAL
static byte
MESSAGE_VERSION_SUPPORTS_PADDING
-
Constructor Summary
Constructors Constructor Description BTMessageFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Message
createBTMessage(DirectByteBuffer stream_payload)
Construct a new BT message instance from the given message raw byte stream.static RawMessage
createBTRawMessage(Message base_message)
Create the proper BT raw message from the given base message.static int
getMessageType(DirectByteBuffer stream_payload)
static void
init()
Initialize the factory, i.e.
-
-
-
Field Detail
-
MESSAGE_VERSION_INITIAL
public static final byte MESSAGE_VERSION_INITIAL
- See Also:
- Constant Field Values
-
MESSAGE_VERSION_SUPPORTS_PADDING
public static final byte MESSAGE_VERSION_SUPPORTS_PADDING
- See Also:
- Constant Field Values
-
LOGID
private static final LogIDs LOGID
-
id_to_name
private static final java.lang.String[] id_to_name
-
legacy_data
private static final java.util.HashMap legacy_data
-
-
Method Detail
-
init
public static void init()
Initialize the factory, i.e. register the messages with the message manager.
-
createBTMessage
public static Message createBTMessage(DirectByteBuffer stream_payload) throws MessageException
Construct a new BT message instance from the given message raw byte stream.- Parameters:
stream_payload
- data- Returns:
- decoded/deserialized BT message
- Throws:
MessageException
- if message creation failed NOTE: Does not auto-return given direct buffer on thrown exception.
-
getMessageType
public static int getMessageType(DirectByteBuffer stream_payload)
-
createBTRawMessage
public static RawMessage createBTRawMessage(Message base_message)
Create the proper BT raw message from the given base message.- Parameters:
base_message
- to create from- Returns:
- BT raw message
-
-