控制器管理与印表机的 JSON 连接,允许多个模块共享相同的连接。 更多...
Public 成员函数 | |
int | ConnectionCount () |
get number of connections. Note each connection can have multiple users. | |
JsonComm | CreateMgmtComm (IComm ptrComm) |
创建或返回允许管理/JSON 通信的现有连接。 更多... | |
JsonComm | CreateMgmtComm (String commDescriptor) |
创建或返回允许管理/JSON 通信的现有连接。 更多... | |
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. | |
静态 Public 成员函数 | |
static JsonCommController | Instance () |
控制器管理与印表机的 JSON 连接,允许多个模块共享相同的连接。
当需要多个模块共享通信资源或更轻松地创建到印表机的连接时,使用此控制器。
为什么需要这个?
管理/跟踪通信连接,使得共享通信资源到单个印表机的对象的实例化变得更容易。
这似乎不重要…似乎没什么用处…
但请记住,上述对象的实例化可能会发生在用户代码的不同部分,一部分代码可能不知道现有的共享连接。通过这样的集中管理/跟踪, 减轻了用户的负担,创造了更好的用户体验(假设代码按预期工作)。
这是一种“可丢弃的”单例模式和工厂模式的混合,为每台印表机创建唯一的通信和 JSON 解析器,并在所有消费者通过 IDisposable 模式 释放资源后管理类资源的释放。
JsonComm CreateMgmtComm | ( | String | commDescriptor | ) |
创建或返回允许管理/JSON 通信的现有连接。
支持的 commDescriptor 类型:
"TCP:ip:port" 注意:释放时的描述符必须与 ReleaseMgmtComm 的调用完全匹配。