public class Client extends Object
ConnectionManager.invokeWithClientSession(int, ConnectionManager.ClientTask, String) must be used.| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_MENU_BATCH_SIZE
The default maximum number of menu items we will request at a single time.
|
static NumberField |
GREETING_FIELD
The greeting message exchanged over a new connection consists of a 4-byte number field containing the value 1.
|
int |
posingAsPlayer
The player we are pretending to be.
|
int |
targetPlayer
The player number we are communicating with.
|
| Modifier and Type | Method and Description |
|---|---|
static NumberField |
buildRMS1(int requestingPlayer,
Message.MenuIdentifier targetMenu,
CdjStatus.TrackSourceSlot slot)
Build the R:M:S:1 parameter that begins many queries.
|
NumberField |
buildRMS1(Message.MenuIdentifier targetMenu,
CdjStatus.TrackSourceSlot slot)
Build the R:M:S:1 parameter that begins many queries.
|
static long |
getMenuBatchSize()
Ghe maximum number of menu items we will request at a single time.
|
boolean |
isConnected()
Check whether our connection is still available for use.
|
Message |
menuRequest(Message.KnownType requestType,
Message.MenuIdentifier targetMenu,
CdjStatus.TrackSourceSlot slot,
Field... arguments)
Send a request for a menu that we will retrieve items from in subsequent requests.
|
List<Message> |
renderMenuItems(Message.MenuIdentifier targetMenu,
CdjStatus.TrackSourceSlot slot,
int offset,
int count)
Gather up the specified range of responses for a menu request.
|
List<Message> |
renderMenuItems(Message.MenuIdentifier targetMenu,
CdjStatus.TrackSourceSlot slot,
Message availableResponse)
Gather up all the responses that are available for a menu request.
|
static void |
setMenuBatchSize(long batchSize)
Set the maximum number of menu items we will request at a single time.
|
Message |
simpleRequest(Message.KnownType requestType,
Message.KnownType responseType,
Field... arguments)
Send a request that expects a single message as its response, then read and return that response.
|
String |
toString() |
boolean |
tryLockingForMenuOperations(long timeout,
TimeUnit unit)
Attempt to secure exclusive access to this player for performing a menu operation, which requires multiple
request/response cycles.
|
void |
unlockForMenuOperations()
Allow other threads to perform menu operations.
|
public final int targetPlayer
public final int posingAsPlayer
public static final NumberField GREETING_FIELD
public static final long DEFAULT_MENU_BATCH_SIZE
public boolean isConnected()
true if this instance can still be used to query the connected dbserverpublic static NumberField buildRMS1(int requestingPlayer, Message.MenuIdentifier targetMenu, CdjStatus.TrackSourceSlot slot)
Build the R:M:S:1 parameter that begins many queries.
Many request messages take, as their first argument, a 4-byte value where each byte has a special meaning.
The first byte is the player number of the requesting player. The second identifies the menu into which
the response is being loaded, as described by Message.MenuIdentifier. The third specifies the media
slot from which information is desired, as described by CdjStatus.TrackSourceSlot, and the fourth
byte always seems to be 1 (Austin's libpdjl called it sourceAnalyzed).
requestingPlayer - the player number that is asking the questiontargetMenu - the destination for the response to this queryslot - the media library of interest for this querypublic NumberField buildRMS1(Message.MenuIdentifier targetMenu, CdjStatus.TrackSourceSlot slot)
Build the R:M:S:1 parameter that begins many queries.
Many request messages take, as their first argument, a 4-byte value where each byte has a special meaning.
The first byte is the player number of the requesting player. The second identifies the menu into which
the response is being loaded, as described by Message.MenuIdentifier. The third specifies the media
slot from which information is desired, as described by CdjStatus.TrackSourceSlot, and the fourth
byte always seems to be 1 (Austin's libpdjl called it sourceAnalyzed).
targetMenu - the destination for the response to this queryslot - the media library of interest for this querypublic Message simpleRequest(Message.KnownType requestType, Message.KnownType responseType, Field... arguments) throws IOException
requestType - identifies what kind of request to sendresponseType - identifies the type of response we expect, or null if we’ll accept anythingarguments - The argument fields to send in the requestIOException - if there is a communication problem, or if the response does not have the same transaction
ID as the request.public Message menuRequest(Message.KnownType requestType, Message.MenuIdentifier targetMenu, CdjStatus.TrackSourceSlot slot, Field... arguments) throws IOException
requestType - identifies what kind of menu request to sendtargetMenu - the destination for the response to this queryslot - the media library of interest for this queryarguments - the additional arguments needed, if any, to complete the requestMessage.KnownType.MENU_AVAILABLE response reporting how many items are available in the menuIOException - if there is a problem communicating, or if the requested menu is not availableIllegalStateException - if tryLockingForMenuOperations(long, TimeUnit) was not called successfully
before attempting this callpublic static long getMenuBatchSize()
renderMenuItems(Message.MenuIdentifier, CdjStatus.TrackSourceSlot, Message).renderMenuItems(Message.MenuIdentifier, CdjStatus.TrackSourceSlot, Message)
will request at oncepublic static void setMenuBatchSize(long batchSize)
renderMenuItems(Message.MenuIdentifier, CdjStatus.TrackSourceSlot, Message).batchSize - the maximum number of items renderMenuItems(Message.MenuIdentifier, CdjStatus.TrackSourceSlot, Message)
will request at oncepublic boolean tryLockingForMenuOperations(long timeout,
TimeUnit unit)
throws InterruptedException
unlockForMenuOperations() as soon as it is
done (even if it is failing because of an exception), or no future menu operations will be possible by any
other thread, unless false was returned, meaning the attempt failed.timeout - the time to wait for the lockunit - the time unit of the timeout argumenttrue if the lock was acquired within the specified timeInterruptedException - if the thread is interrupted while waiting for the lockpublic void unlockForMenuOperations()
tryLockingForMenuOperations(long, TimeUnit) was called with a true return value.public List<Message> renderMenuItems(Message.MenuIdentifier targetMenu, CdjStatus.TrackSourceSlot slot, Message availableResponse) throws IOException
getMenuBatchSize().targetMenu - the destination for the response to this queryslot - the media library of interest for this queryavailableResponse - the response to the initial menu setup request, reporting how many responses are
available, as well as the target menu we are working withIOException - if there is a problem reading the menu itemsIllegalStateException - if tryLockingForMenuOperations(long, TimeUnit) was not called successfully
before attempting this callpublic List<Message> renderMenuItems(Message.MenuIdentifier targetMenu, CdjStatus.TrackSourceSlot slot, int offset, int count) throws IOException
getMenuBatchSize().
It is the caller's responsibility to make sure that offset and count remain within the
legal, available menu items based on the initial menu setup request. Most use cases will be best served
by the simpler renderMenuItems(Message.MenuIdentifier, CdjStatus.TrackSourceSlot, Message).targetMenu - the destination for the response to this queryslot - the media library of interest for this queryoffset - the first response desired (the first one available has offset 0)count - the number of responses desiredIOException - if there is a problem reading the menu itemsIllegalStateException - if tryLockingForMenuOperations(long, TimeUnit) was not called successfully
before attempting this callCopyright © 2016–2018 Deep Symmetry, LLC. All rights reserved.