UniPRT SDK  v1.0.0.0
UniPRT.Sdk.Mgmt.Messenger Class Reference

Class to facilitate management message communication with printer. More...

Inheritance diagram for UniPRT.Sdk.Mgmt.Messenger:
UniPRT.Sdk.Mgmt.IMgmtMessenger

Public Member Functions

 Messenger (IComm commToPtr, int maxInputMsgCapacity=100, MgmtChannelFilterType listenerType=MgmtChannelFilterType.MY_SOLICITED_MSGS_ONLY, bool usingDataPort=false)
 Creates a channel for sending/receiving management messages with a maximum capacity specified. More...
 
void Dispose ()
 
MgmtMsg ReadNextMsg ()
 Read next message that may have been received asynchronously from printer.
 
string SendMsg (string command, string content, string TrackNo="")
 Send a management command and data/content to printer. More...
 
MgmtMsg SendMsgAndWaitForResponse (string command, string content, int maxWaitTimeSecs=6)
 Send a management command and data/content to printer and wait for response maxWaitTimeSecs time. More...
 
void SendMsgRaw (string dataToSend)
 Sends contents without any message formatting directly to printer. More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 

Properties

string ID [get]
 The ID that differentiates different message senders communicating with printer at same time. ID used in the "To"/"From" in the MgmtMsg
 
int UnreadMsgCount [get]
 

Detailed Description

Class to facilitate management message communication with printer.

Constructor & Destructor Documentation

◆ Messenger()

UniPRT.Sdk.Mgmt.Messenger.Messenger ( IComm  commToPtr,
int  maxInputMsgCapacity = 100,
MgmtChannelFilterType  listenerType = MgmtChannelFilterType.MY_SOLICITED_MSGS_ONLY,
bool  usingDataPort = false 
)

Creates a channel for sending/receiving management messages with a maximum capacity specified.

The oldest message is dropped if messages not read before more messages received from 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 printer differentiates the messages from print data.

Member Function Documentation

◆ SendMsg()

string 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 UniPRT.Sdk.Mgmt.IMgmtMessenger.

◆ SendMsgAndWaitForResponse()

MgmtMsg UniPRT.Sdk.Mgmt.Messenger.SendMsgAndWaitForResponse ( string  command,
string  content,
int  maxWaitTimeSecs = 6 
)

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 UniPRT.Sdk.Mgmt.IMgmtMessenger.

◆ SendMsgRaw()

void 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 UniPRT.Sdk.Mgmt.IMgmtMessenger.