-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsolClient.py
285 lines (249 loc) · 12.6 KB
/
solClient.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#! /usr/local/bin/python
#
# This module exposes part of the Solace Messaging C API to Python 2.7
#
#
from ctypes import *
libsolclient = cdll.LoadLibrary('lib/libsolclient.so.1')
#
# typedef enum solClient_log_level
# {
# SOLCLIENT_LOG_EMERGENCY = 0, /**< This level is not used by the API. */
# SOLCLIENT_LOG_ALERT = 1, /**< This level is not used by the API. */
# SOLCLIENT_LOG_CRITICAL = 2, /**< A serious error that can make the API unusable. */
# SOLCLIENT_LOG_ERROR = 3, /**< An unexpected condition within the API that can affect its operation. */
# SOLCLIENT_LOG_WARNING = 4, /**< An unexpected condition within the API that is not expected to affect its operation. */
# SOLCLIENT_LOG_NOTICE = 5, /**< Significant informational messages about the normal operation of the API. These messages are never output in the normal process of sending or receiving a message from the appliance. */
# SOLCLIENT_LOG_INFO = 6, /**< Informational messages about the normal operation of the API. These might include information related to sending or receiving messages from the appliance. */
# SOLCLIENT_LOG_DEBUG = 7 /**< Debugging information generally useful to API developers (very verbose). */
# } solClient_log_level_t; /**< Type for log levels. */
#
(SOLCLIENT_LOG_EMERGENCY,
SOLCLIENT_LOG_ALERT,
SOLCLIENT_LOG_CRITICAL,
SOLCLIENT_LOG_ERROR,
SOLCLIENT_LOG_WARNING,
SOLCLIENT_LOG_NOTICE,
SOLCLIENT_LOG_INFO,
SOLCLIENT_LOG_DEBUG) = map(c_int, xrange(8))
solClient_log_level_t = c_int
#
# #define SOLCLIENT_LOG_DEFAULT_FILTER (SOLCLIENT_LOG_NOTICE) /**< Default log filter level. */
#
SOLCLIENT_LOG_DEFAULT_FILTER = SOLCLIENT_LOG_NOTICE
#
# #define SOLCLIENT_CONTEXT_PROPS_DEFAULT_WITH_CREATE_THREAD ((solClient_propertyArray_pt )_solClient_contextPropsDefaultWithCreateThread) /**< Use with ::solClient_context_create() to create a Context in which the automatic Context thread is automatically created and all other properties are set with default values. */
#
SOLCLIENT_CONTEXT_PROPS_DEFAULT_WITH_CREATE_THREAD = pointer(
c_char_p.in_dll(libsolclient, "_solClient_contextPropsDefaultWithCreateThread")
)
#
# #define SOLCLIENT_DELIVERY_MODE_DIRECT (0x00) /**< Send a Direct message. */
# #define SOLCLIENT_DELIVERY_MODE_PERSISTENT (0x10) /**< Send a Persistent message. */
# #define SOLCLIENT_DELIVERY_MODE_NONPERSISTENT (0x20) /**< Send a Non-Persistent message. */
#
SOLCLIENT_DELIVERY_MODE_DIRECT = c_int(0)
#
# #define SOLCLIENT_SUBSCRIBE_FLAGS_WAITFORCONFIRM (0x02) /**< The subscribe/unsubscribe call blocks until a confirmation is received. @see @ref blocking-context "Threading Effects on Blocking Modes" for more information about setting subscribe flags in the Context thread.*/
# #define SOLCLIENT_SUBSCRIBE_FLAGS_RX_ALL_DELIVER_TO_ONE (0x04) /**< This flag, when present in a subscription ADD request, overrides the deliver-to-one property in a message (see ::solClient_msg_setDeliverToOne()) - If the Topic in the message matches, it is delivered to clients with ::SOLCLIENT_SUBSCRIBE_FLAGS_RX_ALL_DELIVER_TO_ONE set, in addition to any one client that is subscribed to the Topic without this override. */
# #define SOLCLIENT_SUBSCRIBE_FLAGS_LOCAL_DISPATCH_ONLY (0x08) /**< For the @ref topic-dispatch "topic dispatch" feature, this flag indicates the subscription should only be added to the dispatch table and should not be added to the appliance. */
# #define SOLCLIENT_SUBSCRIBE_FLAGS_REQUEST_CONFIRM (0x10) /**< Requests a confirmation for the subscribe/unsubscribe operation. This bit is implied by ::SOLCLIENT_SUBSCRIBE_FLAGS_WAITFORCONFIRM. If ::SOLCLIENT_SUBSCRIBE_FLAGS_WAITFORCONFIRM is not set when this flag is set, then a confirmation event will be issued through the Session event callback procedure. */
#
SOLCLIENT_SUBSCRIBE_FLAGS_WAITFORCONFIRM = c_int(2)
#
# typedef void *solClient_opaqueContext_pt; /**< An opaque pointer to a processing Context. */
# typedef void *solClient_opaqueSession_pt; /**< An opaque pointer to a Session. */
# typedef void *solClient_opaqueMsg_pt; /**< An opaque pointer to a message. */
#
solClient_opaqueContext_pt = c_void_p
solClient_opaqueSession_pt = c_void_p
solClient_opaqueMsg_pt = c_void_p
#
# typedef struct solClient_context_createRegisterFdFuncInfo
# {
# solClient_context_registerFdFunc_t regFdFunc_p;
# solClient_context_unregisterFdFunc_t unregFdFunc_p;
# void *user_p;
# } solClient_context_createRegisterFdFuncInfo_t;
#
# typedef struct solClient_context_createFuncInfo
# {
# solClient_context_createRegisterFdFuncInfo_t regFdInfo;
# } solClient_context_createFuncInfo_t;
#
class solClient_context_createRegisterFdFuncInfo_t(Structure):
_fields_ = [
("regFdFunc_p", c_void_p),
("unregFdFunc_p", c_void_p),
("user_p", c_void_p)
]
class solClient_context_createFuncInfo_t(Structure):
_fields_ = [
("regFdInfo", solClient_context_createRegisterFdFuncInfo_t)
]
#
# typedef struct solClient_session_createRxCallbackFuncInfo
# {
# void *callback_p;
# void *user_p;
# } solClient_session_createRxCallbackFuncInfo_t;
#
# typedef struct solClient_session_eventCallbackInfo
# {
# solClient_session_event_t sessionEvent; /**< The Session event that has occurred. */
# solClient_session_responseCode_t responseCode; /**< A response code that is returned for some events, otherwise zero. */
# const char *info_p; /**< Except for ::SOLCLIENT_SESSION_EVENT_ACKNOWLEDGEMENT (see Detailed Description above), a pointer to a NULL-terminated string providing further information about the event, when available. This pointer is never NULL */
# void *correlation_p; /**< Application-supplied correlation pointer where applicable. Used when acknowledging or rejecting Guaranteed messages, in responses to any function calls that pass a correlationTag that will be returned in a Session Event. */
# } solClient_session_eventCallbackInfo_t, *solClient_session_eventCallbackInfo_pt; /**< A pointer to ::solClient_session_eventCallbackInfo structure of information returned with a Session event. */
#
# typedef void (*solClient_session_eventCallbackFunc_t) (solClient_opaqueSession_pt opaqueSession_p, solClient_session_eventCallbackInfo_pt eventInfo_p, void *user_p);
#
# typedef struct solClient_session_createEventCallbackFuncInfo
# {
# solClient_session_eventCallbackFunc_t callback_p;
# void *user_p;
# } solClient_session_createEventCallbackFuncInfo_t;
#
# typedef struct solClient_session_createRxCallbackFuncInfo
# {
# void *callback_p;
# void *user_p;
# } solClient_session_createRxCallbackFuncInfo_t;
#
# typedef struct solClient_session_createFuncInfo
# {
# solClient_session_createRxCallbackFuncInfo_t rxInfo;
# solClient_session_createEventCallbackFuncInfo_t eventInfo;
# solClient_session_createRxMsgCallbackFuncInfo_t rxMsgInfo;
# } solClient_session_createFuncInfo_t;
#
class solClient_session_createRxCallbackFuncInfo_t(Structure):
_fields_ = [
("callback_p", c_void_p),
("user_p", c_void_p)
]
# TODO (Update the types of these fields)
class solClient_session_eventCallbackInfo_t(Structure):
_fields_ = [
("sessionEvent", c_void_p),
("responseCode", c_void_p),
("info_p", c_char_p),
("correlation_p", c_void_p)
]
solClient_session_eventCallbackInfo_pt = POINTER(solClient_session_eventCallbackInfo_t)
solClient_session_eventCallbackFunc_t = CFUNCTYPE(c_int, solClient_opaqueSession_pt, solClient_session_eventCallbackInfo_pt, c_void_p)
class solClient_session_createEventCallbackFuncInfo_t(Structure):
_fields_ = [
("callback_p", solClient_session_eventCallbackFunc_t),
("user_p", c_void_p)
]
solClient_session_rxMsgCallbackFunc_t = CFUNCTYPE(c_int, solClient_opaqueSession_pt, solClient_opaqueMsg_pt, c_void_p)
class solClient_session_createRxMsgCallbackFuncInfo_t(Structure):
_fields_ = [
("callback_p", c_void_p),
("user_p", c_void_p)
]
class solClient_session_createFuncInfo_t(Structure):
_fields_ = [
("rxInfo", solClient_session_createRxCallbackFuncInfo_t),
("eventInfo", solClient_session_createEventCallbackFuncInfo_t),
("rxMsgInfo", solClient_session_createRxMsgCallbackFuncInfo_t)
]
SOLCLIENT_SESSION_PROP_USERNAME = c_char_p("SESSION_USERNAME")
SOLCLIENT_SESSION_PROP_HOST = c_char_p("SESSION_HOST")
SOLCLIENT_SESSION_PROP_VPN_NAME = c_char_p("SESSION_VPN_NAME")
#
# typedef enum solClient_destinationType
# {
# SOLCLIENT_NULL_DESTINATION = -1,
# SOLCLIENT_TOPIC_DESTINATION = 0,
# SOLCLIENT_QUEUE_DESTINATION = 1,
# SOLCLIENT_TOPIC_TEMP_DESTINATION = 2,
# SOLCLIENT_QUEUE_TEMP_DESTINATION = 3
# } solClient_destinationType_t;
#
# typedef struct solClient_destination
# {
# solClient_destinationType_t destType; /**< The type of destination. */
# const char * dest; /**< The name of the destination (as a NULL-terminated string). */
# } solClient_destination_t;
#
(SOLCLIENT_NULL_DESTINATION,
SOLCLIENT_TOPIC_DESTINATION,
SOLCLIENT_QUEUE_DESTINATION,
SOLCLIENT_TOPIC_TEMP_DESTINATION,
SOLCLIENT_QUEUE_TEMP_DESTINATION) = map(c_int, xrange(-1, 4))
solClient_destinationType_t = c_int
class solClient_destination_t(Structure):
_fields_ = [
("destType", solClient_destinationType_t),
("dest", c_char_p)
]
#
# solClient_dllExport solClient_returnCode_t
# solClient_initialize (solClient_log_level_t initialLogLevel,
# solClient_propertyArray_pt props);
#
def solClient_initialize(initialLogLevel=SOLCLIENT_LOG_DEFAULT_FILTER, props=None):
libsolclient.solClient_initialize(initialLogLevel, props)
#
# solClient_dllExport solClient_returnCode_t
# solClient_context_create (solClient_propertyArray_pt props,
# solClient_opaqueContext_pt * opaqueContext_p,
# solClient_context_createFuncInfo_t * funcInfo_p,
# size_t funcInfoSize);
#
def solClient_context_create(props, opaqueContext_p, funcInfo_p, funcInfoSize):
libsolclient.solClient_context_create(props, opaqueContext_p, funcInfo_p, funcInfoSize)
#
# solClient_dllExport solClient_returnCode_t
# solClient_session_create (solClient_propertyArray_pt props,
# solClient_opaqueContext_pt opaqueContext_p,
# solClient_opaqueSession_pt * opaqueSession_p,
# solClient_session_createFuncInfo_t * funcInfo_p,
# size_t funcInfoSize);
#
def solClient_session_create(props, opaqueContext_p, opaqueSession_p, funcInfo_p, funcInfoSize):
libsolclient.solClient_session_create(props, opaqueContext_p, opaqueSession_p, funcInfo_p, funcInfoSize)
#
# solClient_dllExport solClient_returnCode_t
# solClient_session_connect (solClient_opaqueSession_pt opaqueSession_p);
#
def solClient_session_connect(opaqueSession_p):
libsolclient.solClient_session_connect(opaqueSession_p)
#
# solClient_dllExport solClient_returnCode_t
# solClient_session_disconnect (solClient_opaqueSession_pt opaqueSession_p);
#
def solClient_session_disconnect(opaqueSession_p):
libsolclient.solClient_session_disconnect(opaqueSession_p)
#
# solClient_dllExport solClient_returnCode_t
# solClient_session_topicSubscribeExt (
# solClient_opaqueSession_pt opaqueSession_p,
# solClient_subscribeFlags_t flags,
# const char *topicSubscription_p);
#
def solClient_session_topicSubscribeExt(opaqueSession_p, flags, topicSubscription_p):
libsolclient.solClient_session_topicSubscribeExt(opaqueSession_p, flags, topicSubscription_p)
#
# solClient_dllExport solClient_returnCode_t
# solClient_session_topicUnsubscribeExt (solClient_opaqueSession_pt
# opaqueSession_p,
# solClient_subscribeFlags_t flags,
# const char *topicSubscription_p);
#
def solClient_session_topicUnsubscribeExt(opaqueSession_p, flags, topicSubscription_p):
libsolclient.solClient_session_topicUnsubscribeExt(opaqueSession_p, flags, topicSubscription_p)
#
# solClient_dllExport solClient_returnCode_t
# solClient_session_sendMsg (solClient_opaqueSession_pt opaqueSession_p,
# solClient_opaqueMsg_pt msg_p);
#
def solClient_session_sendMsg(opaqueSession_p, msg_p):
libsolclient.solClient_session_sendMsg(opaqueSession_p, msg_p)
#
# solClient_dllExport solClient_returnCode_t solClient_cleanup (void);
#
def solClient_cleanup():
libsolclient.solClient_cleanup()