Class Message
- java.lang.Object
-
- org.deepsymmetry.beatlink.dbserver.Message
-
public class Message extends Object
Encapsulates a full dbserver message, made up of a list of
Fieldobjects, and having a particular structure, as described in the Packet Analysis document.Known message types are found in
Message.KnownType. Many requests return a series of messages that represent menu items; the known versions of these are reflected inMessage.MenuItemType.- Author:
- James Elliott
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMessage.KnownTypeDefines all the message types we know about, with any information we know about their arguments.static classMessage.MenuIdentifierFor many types of query messages, the first argument of the message is a 4-byte integer which we currently refer to as r:m:s:t, because the first byte is the player number of the player making the request, the second byte identifies the menu or destination for which information is being loaded, the third byte identifies the media slot (USB or SD) being asked about (as described inCdjStatus.TrackSourceSlot), and the fourth byte identifies the type of track being worked with (for most requests this is 1, meaning rekordbox).static classMessage.MenuItemTypeDefines all the known types of entries that an be returned for a menu request.
-
Field Summary
Fields Modifier and Type Field Description static intALNZ_FILE_TYPE_DATThe value to pass for the file type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain an element of an ANLZnnnn.DAT file.static intALNZ_FILE_TYPE_EXTThe value to pass for the file type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain an element of an ANLZnnnn.EXT file.static intANLZ_FILE_TAG_COLOR_WAVEFORM_DETAILThe value to pass for the tag type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain the scrollable color waveform data.static intANLZ_FILE_TAG_COLOR_WAVEFORM_PREVIEWThe value to pass for the tag type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain the color waveform preview data.static intANLZ_FILE_TAG_CUE_COMMENTThe value to pass for the tag type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain the enhanced cue and loop data, but does not seem to work.static intANLZ_FILE_TAG_SONG_STRUCTUREThe value to pass for the tag type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain the song structure information data.NumberFieldargumentCountThe 1-byte number field that specifies how many arguments the message has.List<Field>argumentsThe arguments being sent as part of this message.List<Field>fieldsThe entire list of fields that make up the message.static Map<Long,Message.KnownType>KNOWN_TYPE_MAPAllows a known message type to be looked up by the message type number.Message.KnownTypeknownTypeThe recognized type, if any, of this message.static Map<Byte,Message.MenuIdentifier>MENU_IDENTIFIER_MAPAllows a menu/destination to be looked up by the value seen in the second byte of the first argument of many request messages.static Map<Long,Message.MenuItemType>MENU_ITEM_TYPE_MAPAllows a menu item type to be looked up by the value seen in the seventh argument of aMessage.KnownType.MENU_ITEMresponse.static NumberFieldMESSAGE_STARTThe special field that marks the start of a new message.NumberFieldmessageTypeThe 2-byte number field that identifies what type of message this is, immediately following the transaction sequence number.static longNO_MENU_RESULTS_AVAILABLEThe value returned bygetMenuResultsCount()when there is no data available for the request that was made.NumberFieldtransactionThe 4-byte number field that provides the sequence number tying a query to its response messages, immediately following the message start field.
-
Constructor Summary
Constructors Constructor Description Message(long transaction, long messageType, Field... arguments)Constructor for experimenting with new message types.Message(long transaction, Message.KnownType messageType, Field... arguments)Constructor from code using known message types.Message(NumberField transaction, NumberField messageType, Field... arguments)Constructor when being read from the network, so already have all the fields created.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Message.MenuItemTypegetMenuItemType()Extracts the menu item type from aMessage.KnownType.MENU_ITEMresponse.longgetMenuResultsCount()Extracts the result count from aMessage.KnownType.MENU_AVAILABLEresponse.static Messageread(DataInputStream is)Read the next message from the stream.StringtoString()voidwrite(WritableByteChannel channel)Writes the message to the specified channel, for example when saving to a file (like a Beat Link Trigger show).
-
-
-
Field Detail
-
MESSAGE_START
public static final NumberField MESSAGE_START
The special field that marks the start of a new message.
-
KNOWN_TYPE_MAP
public static final Map<Long,Message.KnownType> KNOWN_TYPE_MAP
Allows a known message type to be looked up by the message type number.
-
ALNZ_FILE_TYPE_DAT
public static final int ALNZ_FILE_TYPE_DAT
The value to pass for the file type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain an element of an ANLZnnnn.DAT file. (The characters "DAT" and NUL as a byte-swapped integer.)- See Also:
- Constant Field Values
-
ALNZ_FILE_TYPE_EXT
public static final int ALNZ_FILE_TYPE_EXT
The value to pass for the file type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain an element of an ANLZnnnn.EXT file. (The characters "EXT" and NUL as a byte-swapped integer.)- See Also:
- Constant Field Values
-
ANLZ_FILE_TAG_COLOR_WAVEFORM_PREVIEW
public static final int ANLZ_FILE_TAG_COLOR_WAVEFORM_PREVIEW
The value to pass for the tag type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain the color waveform preview data. (The characters "PWV4" as a byte-swapped integer.)- See Also:
- Constant Field Values
-
ANLZ_FILE_TAG_COLOR_WAVEFORM_DETAIL
public static final int ANLZ_FILE_TAG_COLOR_WAVEFORM_DETAIL
The value to pass for the tag type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain the scrollable color waveform data. (The characters "PWV5" as a byte-swapped integer.)- See Also:
- Constant Field Values
-
ANLZ_FILE_TAG_SONG_STRUCTURE
public static final int ANLZ_FILE_TAG_SONG_STRUCTURE
The value to pass for the tag type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain the song structure information data. (The characters "PSSI" as a byte-swapped integer.)- See Also:
- Constant Field Values
-
ANLZ_FILE_TAG_CUE_COMMENT
public static final int ANLZ_FILE_TAG_CUE_COMMENT
The value to pass for the tag type argument of aMessage.KnownType.ANLZ_TAG_REQrequest in order to obtain the enhanced cue and loop data, but does not seem to work. (The characters "PCO2" as a byte-swapped integer.)- See Also:
- Constant Field Values
-
MENU_ITEM_TYPE_MAP
public static final Map<Long,Message.MenuItemType> MENU_ITEM_TYPE_MAP
Allows a menu item type to be looked up by the value seen in the seventh argument of aMessage.KnownType.MENU_ITEMresponse.
-
transaction
public final NumberField transaction
The 4-byte number field that provides the sequence number tying a query to its response messages, immediately following the message start field.
-
messageType
public final NumberField messageType
The 2-byte number field that identifies what type of message this is, immediately following the transaction sequence number.
-
knownType
public final Message.KnownType knownType
The recognized type, if any, of this message.
-
argumentCount
public final NumberField argumentCount
The 1-byte number field that specifies how many arguments the message has.
-
MENU_IDENTIFIER_MAP
public static final Map<Byte,Message.MenuIdentifier> MENU_IDENTIFIER_MAP
Allows a menu/destination to be looked up by the value seen in the second byte of the first argument of many request messages.
-
NO_MENU_RESULTS_AVAILABLE
public static final long NO_MENU_RESULTS_AVAILABLE
The value returned bygetMenuResultsCount()when there is no data available for the request that was made.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Message
public Message(long transaction, long messageType, Field... arguments)Constructor for experimenting with new message types.- Parameters:
transaction- the transaction ID (sequence number) that ties a message to its responsesmessageType- identifies the purpose and structure of the messagearguments- the arguments to send with the message
-
Message
public Message(long transaction, Message.KnownType messageType, Field... arguments)Constructor from code using known message types.- Parameters:
transaction- the transaction ID (sequence number) that ties a message to its responsesmessageType- identifies the purpose and structure of the messagearguments- the arguments to send with the message
-
Message
public Message(NumberField transaction, NumberField messageType, Field... arguments)
Constructor when being read from the network, so already have all the fields created.- Parameters:
transaction- the transaction ID (sequence number) that ties a message to its responsesmessageType- identifies the purpose and structure of the messagearguments- the arguments to send with the message
-
-
Method Detail
-
read
public static Message read(DataInputStream is) throws IOException
Read the next message from the stream.- Parameters:
is- a stream connected to a dbserver which is expected to be sending a message.- Returns:
- the next full message found on the stream.
- Throws:
IOException- if there is a problem reading the message.
-
getMenuResultsCount
public long getMenuResultsCount()
Extracts the result count from aMessage.KnownType.MENU_AVAILABLEresponse.- Returns:
- the reported count of available results
- Throws:
IllegalArgumentException- if this is not aMessage.KnownType.MENU_AVAILABLEresponse.
-
getMenuItemType
public Message.MenuItemType getMenuItemType()
Extracts the menu item type from aMessage.KnownType.MENU_ITEMresponse.- Returns:
- the reported type of this menu item
- Throws:
IllegalArgumentException- if this is not aMessage.KnownType.MENU_ITEMresponse.
-
write
public void write(WritableByteChannel channel) throws IOException
Writes the message to the specified channel, for example when saving to a file (like a Beat Link Trigger show).- Parameters:
channel- the channel to which it should be written- Throws:
IOException- if there is a problem writing to the channel
-
-