UniPRT SDK  v1.0.0.0
JsonCommController Class Reference

Controller that manages JSON connections with printer and allows multiple modules to share the same connection. More...

Public Member Functions

int ConnectionCount ()
 get number of connections. Note each connection can have multiple users.
 
JsonComm CreateMgmtComm (IComm ptrComm)
 Creates or returns existing connection that allows for mgmt/JSON communication. More...
 
JsonComm CreateMgmtComm (String commDescriptor)
 Creates or returns existing connection that allows for mgmt/JSON communication. More...
 
List< String > Descriptors ()
 get list of connection descriptors
 
void ReleaseMgmtComm (String commDescriptor)
 Release the json comm resources tied to the commDescriptor
 
int UserCount (String commdDescriptor)
 get the active user count for a given commDescriptor.
 

Static Public Member Functions

static JsonCommController Instance ()
 

Detailed Description

Controller that manages JSON connections with printer and allows multiple modules to share the same connection.

For case where a shared comm resource is needed by multiple modules or to make it easier for connection(s) to printer to be created.

Why is this needed?
Manage/track comm connections to make instantiating of objects that share comm resources to single printer easier.

Doesn't seem like a big deal... Doesn't seem too useful...
But, keep in mind that the above instantiation of objects could happen at different parts of the user's code and one piece of code may not be aware of any existing shared connections to the printer. By doing this centralized manager/tracker, the user's burden is reduced, creating a better user experience (assuming the code works as intended).

This is a hybrid of a "disposable" singleton pattern (only one comm and one JSON parser for each printer) and a factory pattern that creates the instance of the class and manages the release of the class resources when all consumers have released the resource via the IDisposable pattern from each of the consumer classes (the MgmtModules that require comm + json msgs).

Member Function Documentation

◆ CreateMgmtComm() [1/2]

JsonComm CreateMgmtComm ( IComm  ptrComm)

Creates or returns existing connection that allows for mgmt/JSON communication.

ptrComm is the communication connection to printer.

◆ CreateMgmtComm() [2/2]

JsonComm CreateMgmtComm ( String  commDescriptor)

Creates or returns existing connection that allows for mgmt/JSON communication.

commDescriptor types supported:
"TCP:ip:port" NOTE: Descriptors must match exactly when releasing on call to ReleaseMgmtComm