UniPRT SDK v1.0.0.0
 
载入中...
搜索中...
未找到
JsonComm.h
1//
2// JsonMng.h
3// TSCPrinters SDK
4//
5// Created by Realbuber on 2024/4/3.
6//
7
8#ifndef JsonMng_h
9#define JsonMng_h
10
11
12#endif /* JsonMng_h */
13
14
15#import <Foundation/Foundation.h>
16#import <UniPRT/JsonStringTokenizer.h>
17#import <UniPRT/JsonStringBuilder.h>
18#import <UniPRT/ImpChannel.h>
19#import <UniPRT/CancellationToken.h>
20#import <UniPRT/TcpComm.h>
21
31@interface JsonComm : NSObject {
32 BOOL disposed;
33 NSLock *_listenerMutex;
34 NSMutableDictionary *_SolicitedListenerTable;
35 NSMutableArray *_msgListeners_Solicited;
36 CancellationToken *_cancellationTokenSource;
37 JsonStringTokenizer *_jsonStringTokenizer;
38 NSThread *_asyncJsonMsgTransceiverThread;
40 BOOL _Connected;
41 NSMutableArray *_msgListeners_AllMsgs;
42 NSMutableArray *_msgListeners_Unsolicited;
43 NSMutableString *_jsonReceived;
44 NSLock *_semaphoreListeners;
46 // id _commToPtr; /**< Pointer to the communication instance (commented out). */
47 NSInteger _iCommTyp;
48}
49
54typedef NS_ENUM(NSInteger, CommType) {
55 USB_COMM,
56 BT_COMM,
57 TCP_COMM
58};
59
60@property (strong, nonatomic) id commToPtr;
61@property (assign, nonatomic) CommType commType;
62@property (assign, nonatomic) BOOL m_ThIsRunning;
63@property (nonatomic, strong) NSMutableArray *msgListeners_Solicited;
64@property (nonatomic, strong) NSMutableArray *msgListeners_Unsolicited;
65@property (nonatomic, strong) NSMutableArray *msgListeners_AllMsgs;
66@property (nonatomic, strong) NSMutableDictionary<NSString *, ImpChannel *> *solicitedListenerTable;
67@property (nonatomic, strong) ImpChannel *msgOut;
68@property (nonatomic, strong) ImpChannel *MonitorMsgOut;
69@property (nonatomic, strong) ImpChannel *MsgsFromPtr;
70@property (nonatomic, assign) BOOL usingDataPort;
71@property (nonatomic, strong) NSString *solicitedUnsolicitedMsg;
72@property (nonatomic, assign) NSInteger iMsgCount;
78typedef NS_ENUM(NSInteger, ChannelType) {
79 SOLICITED_MSGS_ONLY,
80 UNSOLICITED_MSGS_ONLY,
81 ALL_MSGS
82};
83
87- (void)dispose;
88
94- (void)disposeWithFlag:(BOOL)disposing;
95
101- (void)listenerChannelDisconnect:(ImpChannel *)chnlToRemove;
102
106- (void)start;
107
111- (void)stop;
112
116- (void)stopEx;
117
121- (void)jsonMsgTransceiverTask;
122
129- (NSString *)solicitedChnlKey:(ImpChannel *)chnlToLookFor;
130
138- (instancetype)initWithComm:(id)commToPtr commType:(NSInteger)commType;
139
148- (ImpChannel *)listenerChannelGetNewWithCapacity:(NSInteger)capacity
149 channelType:(ChannelType)channelType
150 solicitedMsgId:(NSString *)solicitedMsgId;
151
157- (void)send:(NSString *)mgmtMsgToSend;
158
164- (ImpChannel *)getImpChannel;
165
171- (TcpComm *)getPtrComm;
172
180- (NSString *)sendAndWaitForResponse:(NSString *)mgmtMsg timeout:(int)respTimeoutMs;
181
182@end
183
一个用于 TCP 通信的类,继承自 AComm 并符合 NSStreamDelegate 协议。
Definition TcpComm.h:101