Class to facilitate management message communication with printer. More...
Public Member Functions | |
Messenger (IComm commToPtr, int maxInputMsgCapacity, MgmtChannelFilterType listenerType, boolean usingDataPort) | |
Creates a channel for sending/receiving management messages with a maximum capacity specified. More... | |
String | GetID () |
The ID that differentiates different message senders communicating with the printer at the same time. The ID is used in the "To"/"From" in the MgmtMsg. More... | |
String | SendMsg (String command, String content, String trackNo) |
Send a management command and data/content to printer. More... | |
String | SendMsg (String command, String content) |
MgmtMsg | SendMsgAndWaitForResponse (String command, String content, int maxWaitTimeSecs) |
Send a management command and data/content to printer and wait for response maxWaitTimeSecs time. More... | |
MgmtMsg | SendMsgAndWaitForResponse (String command, String content) |
void | SendMsgRaw (String dataToSend) |
Sends contents without any message formatting directly to printer. More... | |
int | UnreadMsgCount () |
Get number of unread messages received and waiting to be read. More... | |
MgmtMsg | ReadNextMsg () |
Read next message that may have been received asynchronously from printer. More... | |
void | close () |
Private Member Functions | |
String | NextMsgId () |
Private Attributes | |
boolean | usingDataPort = false |
JsonComm | _mgmtComm |
Channel< String > | _msgsFromPtr |
String | _myMgmtId = "" |
AtomicLong | _trackCount = new AtomicLong(1) |
Class to facilitate management message communication with printer.
com.UniPRT.Sdk.Mgmt.Messenger.Messenger | ( | IComm | commToPtr, |
int | maxInputMsgCapacity, | ||
MgmtChannelFilterType | listenerType, | ||
boolean | usingDataPort | ||
) |
Creates a channel for sending/receiving management messages with a maximum capacity specified.
The oldest message is dropped if messages are not read before more messages are received from the printer.
For more details refer to FullMode
Set usingDataPort to true if the communication to printer commToPtr is through the same port that print data is sent through. This is important in order to properly format management messages so that the printer differentiates the messages from print data.
References com.UniPRT.Sdk.Mgmt.Messenger._mgmtComm, com.UniPRT.Sdk.Mgmt.Messenger._myMgmtId, com.UniPRT.Sdk.Json.JsonComm.ChannelListenerJson(), com.UniPRT.Sdk.Json.JsonCommController.CreateMgmtComm(), com.UniPRT.Sdk.Json.JsonStringBuilder.GetRandomObjectId_Json(), com.UniPRT.Sdk.Json.JsonCommController.Instance(), and com.UniPRT.Sdk.Mgmt.Messenger.usingDataPort.
void com.UniPRT.Sdk.Mgmt.Messenger.close | ( | ) |
References com.UniPRT.Sdk.Json.JsonComm.close().
String com.UniPRT.Sdk.Mgmt.Messenger.GetID | ( | ) |
The ID that differentiates different message senders communicating with the printer at the same time. The ID is used in the "To"/"From" in the MgmtMsg.
References com.UniPRT.Sdk.Mgmt.Messenger._myMgmtId.
|
private |
References com.UniPRT.Sdk.Mgmt.Messenger._trackCount.
Referenced by com.UniPRT.Sdk.Mgmt.Messenger.SendMsg().
MgmtMsg com.UniPRT.Sdk.Mgmt.Messenger.ReadNextMsg | ( | ) |
Read next message that may have been received asynchronously from printer.
Implements com.UniPRT.Sdk.Mgmt.IMgmtMessenger.
References com.UniPRT.Sdk.Mgmt.Messenger._msgsFromPtr, and com.UniPRT.Sdk.Mgmt.Channel< T >.Take().
String com.UniPRT.Sdk.Mgmt.Messenger.SendMsg | ( | String | command, |
String | content | ||
) |
Implements com.UniPRT.Sdk.Mgmt.IMgmtMessenger.
References com.UniPRT.Sdk.Mgmt.Messenger.SendMsg().
String com.UniPRT.Sdk.Mgmt.Messenger.SendMsg | ( | String | command, |
String | content, | ||
String | TrackNo | ||
) |
Send a management command and data/content to printer.
The optional TrackNo is the field used in the JSON command structure sent to printer and can be used by caller to check for response from printer. If no TrackNo is provided, one is generated.
The return string is the TrackNo field used in the JSON message sent to the printer to allow caller to differentiate any response associated with the message sent by comparing the TrackNo field of any response received from printer.
Implements com.UniPRT.Sdk.Mgmt.IMgmtMessenger.
References com.UniPRT.Sdk.Mgmt.Messenger._mgmtComm, com.UniPRT.Sdk.Mgmt.Messenger._myMgmtId, com.UniPRT.Sdk.Json.JsonStringBuilder.CreateMsgFrame_Json(), com.UniPRT.Sdk.Mgmt.Messenger.NextMsgId(), com.UniPRT.Sdk.Json.JsonComm.Send(), and com.UniPRT.Sdk.Mgmt.Messenger.usingDataPort.
Referenced by com.UniPRT.Sdk.Mgmt.Messenger.SendMsg(), and com.UniPRT.Sdk.Mgmt.Messenger.SendMsgAndWaitForResponse().
MgmtMsg com.UniPRT.Sdk.Mgmt.Messenger.SendMsgAndWaitForResponse | ( | String | command, |
String | content | ||
) |
Implements com.UniPRT.Sdk.Mgmt.IMgmtMessenger.
References com.UniPRT.Sdk.Mgmt.Messenger.SendMsgAndWaitForResponse().
MgmtMsg com.UniPRT.Sdk.Mgmt.Messenger.SendMsgAndWaitForResponse | ( | String | command, |
String | content, | ||
int | maxWaitTimeSecs | ||
) |
Send a management command and data/content to printer and wait for response maxWaitTimeSecs time.
Null object returned if no response received before timeout expired.
All messages are discarded until the response to the specific message sent is received. The discarded messages may include any unread/old messages waiting to be read prior to the call to this method.
Implements com.UniPRT.Sdk.Mgmt.IMgmtMessenger.
References com.UniPRT.Sdk.Mgmt.Messenger._msgsFromPtr, com.UniPRT.Sdk.Mgmt.Channel< T >.Poll(), com.UniPRT.Sdk.Mgmt.Messenger.SendMsg(), and com.UniPRT.Sdk.Mgmt.MgmtMsg.TrackNo.
Referenced by com.UniPRT.Sdk.Mgmt.Messenger.SendMsgAndWaitForResponse().
void com.UniPRT.Sdk.Mgmt.Messenger.SendMsgRaw | ( | String | dataToSend | ) |
Sends contents without any message formatting directly to printer.
This is for cases where data needs to be sent without any added management message formatting. If there is a special management message or data need to be sent in a port that is shared for both data and management, this would be used to send data directly to printer.
Implements com.UniPRT.Sdk.Mgmt.IMgmtMessenger.
References com.UniPRT.Sdk.Mgmt.Messenger._mgmtComm, and com.UniPRT.Sdk.Json.JsonComm.Send().
int com.UniPRT.Sdk.Mgmt.Messenger.UnreadMsgCount | ( | ) |
Get number of unread messages received and waiting to be read.
Implements com.UniPRT.Sdk.Mgmt.IMgmtMessenger.
References com.UniPRT.Sdk.Mgmt.Messenger._msgsFromPtr, and com.UniPRT.Sdk.Mgmt.Channel< T >.Size().
|
private |
|
private |
|
private |
|
private |
Referenced by com.UniPRT.Sdk.Mgmt.Messenger.NextMsgId().
|
private |
Referenced by com.UniPRT.Sdk.Mgmt.Messenger.Messenger(), and com.UniPRT.Sdk.Mgmt.Messenger.SendMsg().