quickfix_ruby_ud 2.0.7-aarch64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. checksums.yaml +7 -0
  2. data/ext/quickfix/Acceptor.cpp +257 -0
  3. data/ext/quickfix/Acceptor.h +127 -0
  4. data/ext/quickfix/Allocator.h +9 -0
  5. data/ext/quickfix/Application.h +137 -0
  6. data/ext/quickfix/DOMDocument.h +70 -0
  7. data/ext/quickfix/DataDictionary.cpp +679 -0
  8. data/ext/quickfix/DataDictionary.h +607 -0
  9. data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
  10. data/ext/quickfix/DataDictionaryProvider.h +67 -0
  11. data/ext/quickfix/DatabaseConnectionID.h +98 -0
  12. data/ext/quickfix/DatabaseConnectionPool.h +84 -0
  13. data/ext/quickfix/Dictionary.cpp +157 -0
  14. data/ext/quickfix/Dictionary.h +89 -0
  15. data/ext/quickfix/Event.h +89 -0
  16. data/ext/quickfix/Except.h +39 -0
  17. data/ext/quickfix/Exceptions.h +257 -0
  18. data/ext/quickfix/Field.h +654 -0
  19. data/ext/quickfix/FieldConvertors.cpp +86 -0
  20. data/ext/quickfix/FieldConvertors.h +800 -0
  21. data/ext/quickfix/FieldMap.cpp +254 -0
  22. data/ext/quickfix/FieldMap.h +327 -0
  23. data/ext/quickfix/FieldNumbers.h +44 -0
  24. data/ext/quickfix/FieldTypes.cpp +62 -0
  25. data/ext/quickfix/FieldTypes.h +817 -0
  26. data/ext/quickfix/Fields.h +30 -0
  27. data/ext/quickfix/FileLog.cpp +176 -0
  28. data/ext/quickfix/FileLog.h +110 -0
  29. data/ext/quickfix/FileStore.cpp +369 -0
  30. data/ext/quickfix/FileStore.h +131 -0
  31. data/ext/quickfix/FixCommonFields.h +13 -0
  32. data/ext/quickfix/FixFieldNumbers.h +6132 -0
  33. data/ext/quickfix/FixFields.h +6133 -0
  34. data/ext/quickfix/FixValues.h +5790 -0
  35. data/ext/quickfix/Group.cpp +44 -0
  36. data/ext/quickfix/Group.h +78 -0
  37. data/ext/quickfix/HostDetailsProvider.cpp +79 -0
  38. data/ext/quickfix/HostDetailsProvider.h +44 -0
  39. data/ext/quickfix/HtmlBuilder.h +178 -0
  40. data/ext/quickfix/HttpConnection.cpp +914 -0
  41. data/ext/quickfix/HttpConnection.h +74 -0
  42. data/ext/quickfix/HttpMessage.cpp +229 -0
  43. data/ext/quickfix/HttpMessage.h +112 -0
  44. data/ext/quickfix/HttpParser.cpp +49 -0
  45. data/ext/quickfix/HttpParser.h +49 -0
  46. data/ext/quickfix/HttpServer.cpp +152 -0
  47. data/ext/quickfix/HttpServer.h +76 -0
  48. data/ext/quickfix/Initiator.cpp +310 -0
  49. data/ext/quickfix/Initiator.h +151 -0
  50. data/ext/quickfix/Log.cpp +71 -0
  51. data/ext/quickfix/Log.h +254 -0
  52. data/ext/quickfix/Message.cpp +617 -0
  53. data/ext/quickfix/Message.h +419 -0
  54. data/ext/quickfix/MessageCracker.h +171 -0
  55. data/ext/quickfix/MessageSorters.cpp +101 -0
  56. data/ext/quickfix/MessageSorters.h +185 -0
  57. data/ext/quickfix/MessageStore.cpp +182 -0
  58. data/ext/quickfix/MessageStore.h +164 -0
  59. data/ext/quickfix/Mutex.h +120 -0
  60. data/ext/quickfix/MySQLConnection.h +187 -0
  61. data/ext/quickfix/MySQLLog.cpp +262 -0
  62. data/ext/quickfix/MySQLLog.h +158 -0
  63. data/ext/quickfix/MySQLStore.cpp +323 -0
  64. data/ext/quickfix/MySQLStore.h +161 -0
  65. data/ext/quickfix/MySQLStubs.h +203 -0
  66. data/ext/quickfix/NullStore.cpp +40 -0
  67. data/ext/quickfix/NullStore.h +89 -0
  68. data/ext/quickfix/OdbcConnection.h +241 -0
  69. data/ext/quickfix/OdbcLog.cpp +230 -0
  70. data/ext/quickfix/OdbcLog.h +109 -0
  71. data/ext/quickfix/OdbcStore.cpp +313 -0
  72. data/ext/quickfix/OdbcStore.h +124 -0
  73. data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
  74. data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
  75. data/ext/quickfix/Parser.cpp +111 -0
  76. data/ext/quickfix/Parser.h +50 -0
  77. data/ext/quickfix/PostgreSQLConnection.h +163 -0
  78. data/ext/quickfix/PostgreSQLLog.cpp +263 -0
  79. data/ext/quickfix/PostgreSQLLog.h +157 -0
  80. data/ext/quickfix/PostgreSQLStore.cpp +327 -0
  81. data/ext/quickfix/PostgreSQLStore.h +160 -0
  82. data/ext/quickfix/PostgreSQLStubs.h +203 -0
  83. data/ext/quickfix/Queue.h +66 -0
  84. data/ext/quickfix/QuickfixRuby.cpp +131900 -0
  85. data/ext/quickfix/QuickfixRuby.h +56 -0
  86. data/ext/quickfix/Responder.h +41 -0
  87. data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
  88. data/ext/quickfix/SSLSocketAcceptor.h +186 -0
  89. data/ext/quickfix/SSLSocketConnection.cpp +434 -0
  90. data/ext/quickfix/SSLSocketConnection.h +221 -0
  91. data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
  92. data/ext/quickfix/SSLSocketInitiator.h +203 -0
  93. data/ext/quickfix/SSLStubs.h +129 -0
  94. data/ext/quickfix/Session.cpp +1437 -0
  95. data/ext/quickfix/Session.h +343 -0
  96. data/ext/quickfix/SessionFactory.cpp +314 -0
  97. data/ext/quickfix/SessionFactory.h +84 -0
  98. data/ext/quickfix/SessionID.h +136 -0
  99. data/ext/quickfix/SessionSettings.cpp +165 -0
  100. data/ext/quickfix/SessionSettings.h +283 -0
  101. data/ext/quickfix/SessionState.h +260 -0
  102. data/ext/quickfix/Settings.cpp +160 -0
  103. data/ext/quickfix/Settings.h +56 -0
  104. data/ext/quickfix/SharedArray.h +274 -0
  105. data/ext/quickfix/SocketAcceptor.cpp +216 -0
  106. data/ext/quickfix/SocketAcceptor.h +77 -0
  107. data/ext/quickfix/SocketConnection.cpp +256 -0
  108. data/ext/quickfix/SocketConnection.h +102 -0
  109. data/ext/quickfix/SocketConnector.cpp +112 -0
  110. data/ext/quickfix/SocketConnector.h +76 -0
  111. data/ext/quickfix/SocketInitiator.cpp +241 -0
  112. data/ext/quickfix/SocketInitiator.h +76 -0
  113. data/ext/quickfix/SocketMonitor.h +26 -0
  114. data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
  115. data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
  116. data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
  117. data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
  118. data/ext/quickfix/SocketServer.cpp +163 -0
  119. data/ext/quickfix/SocketServer.h +100 -0
  120. data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
  121. data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
  122. data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
  123. data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
  124. data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
  125. data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
  126. data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
  127. data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
  128. data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
  129. data/ext/quickfix/ThreadedSocketConnection.h +89 -0
  130. data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
  131. data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
  132. data/ext/quickfix/TimeRange.cpp +227 -0
  133. data/ext/quickfix/TimeRange.h +215 -0
  134. data/ext/quickfix/Utility.cpp +639 -0
  135. data/ext/quickfix/Utility.h +255 -0
  136. data/ext/quickfix/UtilitySSL.cpp +1612 -0
  137. data/ext/quickfix/UtilitySSL.h +274 -0
  138. data/ext/quickfix/Values.h +63 -0
  139. data/ext/quickfix/config-all.h +10 -0
  140. data/ext/quickfix/config.h +10 -0
  141. data/ext/quickfix/config_unix.h +178 -0
  142. data/ext/quickfix/config_windows.h +0 -0
  143. data/ext/quickfix/dirent_windows.h +838 -0
  144. data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
  145. data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
  146. data/ext/quickfix/double-conversion/bignum.cc +766 -0
  147. data/ext/quickfix/double-conversion/bignum.h +144 -0
  148. data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
  149. data/ext/quickfix/double-conversion/cached-powers.h +64 -0
  150. data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
  151. data/ext/quickfix/double-conversion/diy-fp.h +118 -0
  152. data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
  153. data/ext/quickfix/double-conversion/double-conversion.h +543 -0
  154. data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
  155. data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
  156. data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
  157. data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
  158. data/ext/quickfix/double-conversion/ieee.h +402 -0
  159. data/ext/quickfix/double-conversion/strtod.cc +557 -0
  160. data/ext/quickfix/double-conversion/strtod.h +45 -0
  161. data/ext/quickfix/double-conversion/utils.h +374 -0
  162. data/ext/quickfix/extconf.rb +76 -0
  163. data/ext/quickfix/index.h +37 -0
  164. data/ext/quickfix/pugiconfig.hpp +77 -0
  165. data/ext/quickfix/pugixml.cpp +13237 -0
  166. data/ext/quickfix/pugixml.hpp +1516 -0
  167. data/ext/quickfix/scope_guard.hpp +215 -0
  168. data/ext/quickfix/stdint_msvc.h +254 -0
  169. data/ext/quickfix/strptime.h +7 -0
  170. data/lib/2.4/quickfix.so +0 -0
  171. data/lib/2.5/quickfix.so +0 -0
  172. data/lib/2.6/quickfix.so +0 -0
  173. data/lib/2.7/quickfix.so +0 -0
  174. data/lib/3.0/quickfix.so +0 -0
  175. data/lib/3.1/quickfix.so +0 -0
  176. data/lib/3.2/quickfix.so +0 -0
  177. data/lib/3.3/quickfix.so +0 -0
  178. data/lib/3.4/quickfix.so +0 -0
  179. data/lib/quickfix40.rb +274 -0
  180. data/lib/quickfix41.rb +351 -0
  181. data/lib/quickfix42.rb +1184 -0
  182. data/lib/quickfix43.rb +3504 -0
  183. data/lib/quickfix44.rb +14040 -0
  184. data/lib/quickfix50.rb +20051 -0
  185. data/lib/quickfix50sp1.rb +23596 -0
  186. data/lib/quickfix50sp2.rb +412444 -0
  187. data/lib/quickfix_fields.rb +79393 -0
  188. data/lib/quickfix_ruby.rb +82 -0
  189. data/lib/quickfixt11.rb +65 -0
  190. data/spec/FIX40.xml +862 -0
  191. data/spec/FIX41.xml +1282 -0
  192. data/spec/FIX42.xml +2743 -0
  193. data/spec/FIX43.xml +4230 -0
  194. data/spec/FIX44.xml +6600 -0
  195. data/spec/FIX50.xml +8142 -0
  196. data/spec/FIX50SP1.xml +9506 -0
  197. data/spec/FIX50SP2.xml +26069 -0
  198. data/spec/FIXT11.xml +252 -0
  199. data/test/DataDictionaryTestCase.rb +268 -0
  200. data/test/DictionaryTestCase.rb +112 -0
  201. data/test/FieldBaseTestCase.rb +24 -0
  202. data/test/MessageStoreTestCase.rb +19 -0
  203. data/test/MessageTestCase.rb +368 -0
  204. data/test/SessionSettingsTestCase.rb +41 -0
  205. metadata +247 -0
@@ -0,0 +1,914 @@
1
+ /****************************************************************************
2
+ ** Copyright (c) 2001-2014
3
+ **
4
+ ** This file is part of the QuickFIX FIX Engine
5
+ **
6
+ ** This file may be distributed under the terms of the quickfixengine.org
7
+ ** license as defined by quickfixengine.org and appearing in the file
8
+ ** LICENSE included in the packaging of this file.
9
+ **
10
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12
+ **
13
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
14
+ **
15
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
16
+ ** not clear to you.
17
+ **
18
+ ****************************************************************************/
19
+
20
+ #ifdef _MSC_VER
21
+ #include "stdafx.h"
22
+ #else
23
+ #include "config.h"
24
+ #include <poll.h>
25
+ #endif
26
+
27
+ #include "HtmlBuilder.h"
28
+ #include "HttpConnection.h"
29
+ #include "HttpMessage.h"
30
+ #include "Session.h"
31
+ #include "Utility.h"
32
+
33
+ using namespace HTML;
34
+
35
+ namespace FIX {
36
+ HttpConnection::HttpConnection(socket_handle s)
37
+ : m_socket(s) {
38
+ #ifdef _MSC_VER
39
+ FD_ZERO(&m_fds);
40
+ FD_SET(m_socket, &m_fds);
41
+ #endif
42
+ }
43
+
44
+ bool HttpConnection::send(const std::string &msg) { return socket_send(m_socket, msg.c_str(), msg.length()) >= 0; }
45
+
46
+ void HttpConnection::disconnect(int error) {
47
+ if (error > 0) {
48
+ send(HttpMessage::createResponse(error));
49
+ }
50
+
51
+ socket_close(m_socket);
52
+ }
53
+
54
+ bool HttpConnection::read() {
55
+ #if _MSC_VER
56
+ struct timeval timeout = {2, 0};
57
+ fd_set readset = m_fds;
58
+ #else
59
+ int timeout = 2000; // 2000ms = 2 seconds
60
+ struct pollfd pfd = {m_socket, POLLIN | POLLPRI, 0};
61
+ #endif
62
+
63
+ try {
64
+ #if _MSC_VER
65
+ // Wait for input (1 second timeout)
66
+ int result = select(0, &readset, 0, 0, &timeout);
67
+ #else
68
+ // Wait for input (2 second timeout)
69
+ int result = poll(&pfd, 1, timeout);
70
+ #endif
71
+
72
+ if (result > 0) // Something to read
73
+ {
74
+ // We can read without blocking
75
+ ssize_t size = socket_recv(m_socket, m_buffer, sizeof(m_buffer));
76
+ if (size <= 0) {
77
+ throw SocketRecvFailed(size);
78
+ }
79
+ m_parser.addToStream(m_buffer, size);
80
+ } else if (result == 0) // Timeout
81
+ {
82
+ disconnect(408);
83
+ return false;
84
+ } else if (result < 0) // Error
85
+ {
86
+ throw SocketRecvFailed(result);
87
+ }
88
+
89
+ processStream();
90
+ return true;
91
+ } catch (SocketRecvFailed &) {
92
+ disconnect();
93
+ return false;
94
+ }
95
+ }
96
+
97
+ bool HttpConnection::readMessage(std::string &msg) EXCEPT(SocketRecvFailed) {
98
+ try {
99
+ return m_parser.readHttpMessage(msg);
100
+ } catch (MessageParseError &) {
101
+ disconnect(400);
102
+ }
103
+ return true;
104
+ }
105
+
106
+ void HttpConnection::processStream() {
107
+ std::string msg;
108
+ try {
109
+ if (!readMessage(msg)) {
110
+ return;
111
+ }
112
+ HttpMessage request(msg);
113
+ processRequest(request);
114
+ } catch (InvalidMessage &) {
115
+ disconnect(400);
116
+ return;
117
+ }
118
+
119
+ return;
120
+ }
121
+
122
+ void HttpConnection::processRequest(const HttpMessage &request) {
123
+ int error = 200;
124
+ std::stringstream h;
125
+ std::stringstream b;
126
+ std::string titleString = "QuickFIX Engine Web Interface";
127
+
128
+ {
129
+ HEAD head(h);
130
+ head.text();
131
+ {
132
+ CENTER center(h);
133
+ center.text();
134
+ {
135
+ TITLE title(h);
136
+ title.text(titleString);
137
+ }
138
+ {
139
+ H1 h1(h);
140
+ h1.text(titleString);
141
+ }
142
+ }
143
+ {
144
+ CENTER center(h);
145
+ center.text();
146
+ {
147
+ A a(h);
148
+ a.href("/").text("HOME");
149
+ }
150
+ h << NBSP;
151
+ {
152
+ A a(h);
153
+ a.href(request.toString()).text("RELOAD");
154
+ }
155
+ }
156
+ HR hr(h);
157
+ hr.text();
158
+ }
159
+
160
+ BODY body(b);
161
+ body.text();
162
+
163
+ try {
164
+ if (request.getRootString() == "/") {
165
+ processRoot(request, h, b);
166
+ } else if (request.getRootString() == "/resetSessions") {
167
+ processResetSessions(request, h, b);
168
+ } else if (request.getRootString() == "/refreshSessions") {
169
+ processRefreshSessions(request, h, b);
170
+ } else if (request.getRootString() == "/enableSessions") {
171
+ processEnableSessions(request, h, b);
172
+ } else if (request.getRootString() == "/disableSessions") {
173
+ processDisableSessions(request, h, b);
174
+ } else if (request.getRootString() == "/session") {
175
+ processSession(request, h, b);
176
+ } else if (request.getRootString() == "/resetSession") {
177
+ processResetSession(request, h, b);
178
+ } else if (request.getRootString() == "/refreshSession") {
179
+ processRefreshSession(request, h, b);
180
+ } else {
181
+ error = 404;
182
+ }
183
+ } catch (std::exception &e) {
184
+ error = 400;
185
+ b << e.what();
186
+ }
187
+
188
+ std::string response = "<HTML>" + h.str() + b.str() + "</HTML>";
189
+ send(HttpMessage::createResponse(error, error == 200 ? response : ""));
190
+
191
+ disconnect();
192
+ }
193
+
194
+ void HttpConnection::processRoot(const HttpMessage &request, std::stringstream &h, std::stringstream &b) {
195
+ TABLE table(b);
196
+ table.border(1).cellspacing(2).width(100).text();
197
+
198
+ {
199
+ CAPTION caption(b);
200
+ caption.text();
201
+ EM em(b);
202
+ em.text();
203
+ b << Session::numSessions() << " Sessions managed by QuickFIX";
204
+ {
205
+ HR hr(b);
206
+ hr.text();
207
+ }
208
+ {
209
+ b << NBSP;
210
+ A a(b);
211
+ a.href("/resetSessions" + request.getParameterString()).text("RESET");
212
+ }
213
+ {
214
+ b << NBSP;
215
+ A a(b);
216
+ a.href("/refreshSessions" + request.getParameterString()).text("REFRESH");
217
+ }
218
+ {
219
+ b << NBSP;
220
+ A a(b);
221
+ a.href("/enableSessions" + request.getParameterString()).text("ENABLE");
222
+ }
223
+ {
224
+ b << NBSP;
225
+ A a(b);
226
+ a.href("/disableSessions" + request.getParameterString()).text("DISABLE");
227
+ }
228
+ }
229
+
230
+ {
231
+ TR tr(b);
232
+ tr.text();
233
+ {
234
+ TD td(b);
235
+ td.align("center").text("Session");
236
+ }
237
+ {
238
+ TD td(b);
239
+ td.align("center").text("ConnectionType");
240
+ }
241
+ {
242
+ TD td(b);
243
+ td.align("center").text("Enabled");
244
+ }
245
+ {
246
+ TD td(b);
247
+ td.align("center").text("Session Time");
248
+ }
249
+ {
250
+ TD td(b);
251
+ td.align("center").text("Logged On");
252
+ }
253
+ {
254
+ TD td(b);
255
+ td.align("center").text("Next Incoming");
256
+ }
257
+ {
258
+ TD td(b);
259
+ td.align("center").text("Next Outgoing");
260
+ }
261
+ }
262
+
263
+ std::set<SessionID> sessions = Session::getSessions();
264
+ for (const SessionID &sessionID : sessions) {
265
+ Session *pSession = Session::lookupSession(sessionID);
266
+ if (!pSession) {
267
+ continue;
268
+ }
269
+
270
+ {
271
+ TR tr(b);
272
+ tr.text();
273
+ {
274
+ TD td(b);
275
+ td.text();
276
+ std::string href = "/session?BeginString=" + sessionID.getBeginString().getValue()
277
+ + "&SenderCompID=" + sessionID.getSenderCompID().getValue()
278
+ + "&TargetCompID=" + sessionID.getTargetCompID().getValue();
279
+ if (sessionID.getSessionQualifier().size()) {
280
+ href += "&SessionQualifier=" + sessionID.getSessionQualifier();
281
+ }
282
+
283
+ A a(b);
284
+ a.href(href).text(sessionID.toString());
285
+ }
286
+ {
287
+ TD td(b);
288
+ td.text(pSession->isInitiator() ? "initiator" : "acceptor");
289
+ }
290
+ {
291
+ TD td(b);
292
+ td.text(pSession->isEnabled() ? "yes" : "no");
293
+ }
294
+ {
295
+ TD td(b);
296
+ td.text(pSession->isSessionTime(UtcTimeStamp::now()) ? "yes" : "no");
297
+ }
298
+ {
299
+ TD td(b);
300
+ td.text(pSession->isLoggedOn() ? "yes" : "no");
301
+ }
302
+ {
303
+ TD td(b);
304
+ td.text(pSession->getExpectedTargetNum());
305
+ }
306
+ {
307
+ TD td(b);
308
+ td.text(pSession->getExpectedSenderNum());
309
+ }
310
+ }
311
+ }
312
+ }
313
+
314
+ void HttpConnection::processResetSessions(const HttpMessage &request, std::stringstream &h, std::stringstream &b) {
315
+ try {
316
+ HttpMessage copy = request;
317
+
318
+ bool confirm = false;
319
+ if (copy.hasParameter("confirm") && copy.getParameter("confirm") != "0") {
320
+ confirm = true;
321
+ std::set<SessionID> sessions = Session::getSessions();
322
+ std::set<SessionID>::iterator session;
323
+ for (session = sessions.begin(); session != sessions.end(); ++session) {
324
+ Session::lookupSession(*session)->reset();
325
+ }
326
+ copy.removeParameter("confirm");
327
+ }
328
+
329
+ if (confirm) {
330
+ h << "<META http-equiv='refresh' content=2;URL='" << "/'>";
331
+ CENTER center(b);
332
+ center.text();
333
+ H2 h2(b);
334
+ h2.text();
335
+ {
336
+ A a(b);
337
+ a.href("/").text("Sessions");
338
+ }
339
+ b << " have been reset";
340
+ } else {
341
+ {
342
+ CENTER center(b);
343
+ center.text();
344
+ H2 h2(b);
345
+ h2.text();
346
+ b << "Are you sure you want to reset all sessions ?";
347
+ }
348
+ {
349
+ CENTER center(b);
350
+ center.text();
351
+ b << "[";
352
+ {
353
+ A a(b);
354
+ a.href(request.toString() + "?confirm=1").text("YES, reset sessions");
355
+ }
356
+ b << "]" << NBSP << "[";
357
+ {
358
+ A a(b);
359
+ a.href("/").text("NO, do not reset sessions");
360
+ }
361
+ b << "]";
362
+ }
363
+ }
364
+ } catch (std::exception &e) {
365
+ b << e.what();
366
+ }
367
+ }
368
+
369
+ void HttpConnection::processRefreshSessions(const HttpMessage &request, std::stringstream &h, std::stringstream &b) {
370
+ try {
371
+ HttpMessage copy = request;
372
+
373
+ bool confirm = false;
374
+ if (copy.hasParameter("confirm") && copy.getParameter("confirm") != "0") {
375
+ confirm = true;
376
+ std::set<SessionID> sessions = Session::getSessions();
377
+ for (const SessionID &sessionID : sessions) {
378
+ Session::lookupSession(sessionID)->refresh();
379
+ }
380
+ copy.removeParameter("confirm");
381
+ }
382
+
383
+ if (confirm) {
384
+ h << "<META http-equiv='refresh' content=2;URL='" << "/'>";
385
+ CENTER center(b);
386
+ center.text();
387
+ H2 h2(b);
388
+ h2.text();
389
+ {
390
+ A a(b);
391
+ a.href("/").text("Sessions");
392
+ }
393
+ b << " have been refreshed";
394
+ } else {
395
+ {
396
+ CENTER center(b);
397
+ center.text();
398
+ H2 h2(b);
399
+ h2.text();
400
+ b << "Are you sure you want to refresh all sessions ?";
401
+ }
402
+ {
403
+ CENTER center(b);
404
+ center.text();
405
+ b << "[";
406
+ {
407
+ A a(b);
408
+ a.href(request.toString() + "?confirm=1").text("YES, refresh sessions");
409
+ }
410
+ b << "]" << NBSP << "[";
411
+ {
412
+ A a(b);
413
+ a.href("/").text("NO, do not refresh sessions");
414
+ }
415
+ b << "]";
416
+ }
417
+ }
418
+ } catch (std::exception &e) {
419
+ b << e.what();
420
+ }
421
+ }
422
+
423
+ void HttpConnection::processEnableSessions(const HttpMessage &request, std::stringstream &h, std::stringstream &b) {
424
+ try {
425
+ HttpMessage copy = request;
426
+
427
+ bool confirm = false;
428
+ if (copy.hasParameter("confirm") && copy.getParameter("confirm") != "0") {
429
+ confirm = true;
430
+ std::set<SessionID> sessions = Session::getSessions();
431
+ for (const SessionID &sessionID : sessions) {
432
+ Session::lookupSession(sessionID)->logon();
433
+ }
434
+ copy.removeParameter("confirm");
435
+ }
436
+
437
+ if (confirm) {
438
+ h << "<META http-equiv='refresh' content=2;URL='" << "/'>";
439
+ CENTER center(b);
440
+ center.text();
441
+ H2 h2(b);
442
+ h2.text();
443
+ {
444
+ A a(b);
445
+ a.href("/").text("Sessions");
446
+ }
447
+ b << " have been enabled";
448
+ } else {
449
+ {
450
+ CENTER center(b);
451
+ center.text();
452
+ H2 h2(b);
453
+ h2.text();
454
+ b << "Are you sure you want to enable all sessions ?";
455
+ }
456
+ {
457
+ CENTER center(b);
458
+ center.text();
459
+ b << "[";
460
+ {
461
+ A a(b);
462
+ a.href(request.toString() + "?confirm=1").text("YES, enable sessions");
463
+ }
464
+ b << "]" << NBSP << "[";
465
+ {
466
+ A a(b);
467
+ a.href("/").text("NO, do not enable sessions");
468
+ }
469
+ b << "]";
470
+ }
471
+ }
472
+ } catch (std::exception &e) {
473
+ b << e.what();
474
+ }
475
+ }
476
+
477
+ void HttpConnection::processDisableSessions(const HttpMessage &request, std::stringstream &h, std::stringstream &b) {
478
+ try {
479
+ HttpMessage copy = request;
480
+
481
+ bool confirm = false;
482
+ if (copy.hasParameter("confirm") && copy.getParameter("confirm") != "0") {
483
+ confirm = true;
484
+ std::set<SessionID> sessions = Session::getSessions();
485
+ for (const SessionID &sessionID : sessions) {
486
+ Session::lookupSession(sessionID)->logout();
487
+ }
488
+ copy.removeParameter("confirm");
489
+ }
490
+
491
+ if (confirm) {
492
+ h << "<META http-equiv='refresh' content=2;URL='" << "/'>";
493
+ CENTER center(b);
494
+ center.text();
495
+ H2 h2(b);
496
+ h2.text();
497
+ {
498
+ A a(b);
499
+ a.href("/").text("Sessions");
500
+ }
501
+ b << " have been disabled";
502
+ } else {
503
+ {
504
+ CENTER center(b);
505
+ center.text();
506
+ H2 h2(b);
507
+ h2.text();
508
+ b << "Are you sure you want to disable all sessions ?";
509
+ }
510
+ {
511
+ CENTER center(b);
512
+ center.text();
513
+ b << "[";
514
+ {
515
+ A a(b);
516
+ a.href(request.toString() + "?confirm=1").text("YES, disable sessions");
517
+ }
518
+ b << "]" << NBSP << "[";
519
+ {
520
+ A a(b);
521
+ a.href("/").text("NO, do not disable sessions");
522
+ }
523
+ b << "]";
524
+ }
525
+ }
526
+ } catch (std::exception &e) {
527
+ b << e.what();
528
+ }
529
+ }
530
+
531
+ void HttpConnection::processSession(const HttpMessage &request, std::stringstream &h, std::stringstream &b) {
532
+ try {
533
+ HttpMessage copy = request;
534
+ std::string url = request.toString();
535
+ std::string beginString = copy.getParameter("BeginString");
536
+ std::string senderCompID = copy.getParameter("SenderCompID");
537
+ std::string targetCompID = copy.getParameter("TargetCompID");
538
+ std::string sessionQualifier;
539
+ if (copy.hasParameter("SessionQualifier")) {
540
+ sessionQualifier = copy.getParameter("SessionQualifier");
541
+ }
542
+
543
+ SessionID sessionID(beginString, senderCompID, targetCompID, sessionQualifier);
544
+ Session *pSession = Session::lookupSession(sessionID);
545
+ if (pSession == 0) {
546
+ throw SessionNotFound();
547
+ }
548
+
549
+ if (copy.hasParameter("Enabled")) {
550
+ copy.getParameter("Enabled") == "0" ? pSession->logout() : pSession->logon();
551
+ copy.removeParameter("Enabled");
552
+ }
553
+ if (copy.hasParameter("Next%20Incoming")) {
554
+ int value = IntConvertor::convert(copy.getParameter("Next%20Incoming"));
555
+ pSession->setNextTargetMsgSeqNum(value <= 0 ? 1 : value);
556
+ copy.removeParameter("Next%20Incoming");
557
+ }
558
+ if (copy.hasParameter("Next%20Outgoing")) {
559
+ int value = IntConvertor::convert(copy.getParameter("Next%20Outgoing"));
560
+ pSession->setNextSenderMsgSeqNum(value <= 0 ? 1 : value);
561
+ copy.removeParameter("Next%20Outgoing");
562
+ }
563
+ if (copy.hasParameter(SEND_REDUNDANT_RESENDREQUESTS)) {
564
+ pSession->setSendRedundantResendRequests(copy.getParameter(SEND_REDUNDANT_RESENDREQUESTS) != "0");
565
+ copy.removeParameter(SEND_REDUNDANT_RESENDREQUESTS);
566
+ }
567
+ if (copy.hasParameter(CHECK_COMPID)) {
568
+ pSession->setCheckCompId(copy.getParameter(CHECK_COMPID) != "0");
569
+ copy.removeParameter(CHECK_COMPID);
570
+ }
571
+ if (copy.hasParameter(CHECK_LATENCY)) {
572
+ pSession->setCheckLatency(copy.getParameter(CHECK_LATENCY) != "0");
573
+ copy.removeParameter(CHECK_LATENCY);
574
+ }
575
+ if (copy.hasParameter(MAX_LATENCY)) {
576
+ int value = IntConvertor::convert(copy.getParameter(MAX_LATENCY));
577
+ pSession->setMaxLatency(value <= 0 ? 1 : value);
578
+ copy.removeParameter(MAX_LATENCY);
579
+ }
580
+ if (copy.hasParameter(LOGON_TIMEOUT)) {
581
+ int value = IntConvertor::convert(copy.getParameter(LOGON_TIMEOUT));
582
+ pSession->setLogonTimeout(value <= 0 ? 1 : value);
583
+ copy.removeParameter(LOGON_TIMEOUT);
584
+ }
585
+ if (copy.hasParameter(LOGOUT_TIMEOUT)) {
586
+ int value = IntConvertor::convert(copy.getParameter(LOGOUT_TIMEOUT));
587
+ pSession->setLogoutTimeout(value <= 0 ? 1 : value);
588
+ copy.removeParameter(LOGOUT_TIMEOUT);
589
+ }
590
+ if (copy.hasParameter(RESET_ON_LOGON)) {
591
+ pSession->setResetOnLogon(copy.getParameter(RESET_ON_LOGON) != "0");
592
+ copy.removeParameter(RESET_ON_LOGON);
593
+ }
594
+ if (copy.hasParameter(RESET_ON_LOGOUT)) {
595
+ pSession->setResetOnLogout(copy.getParameter(RESET_ON_LOGOUT) != "0");
596
+ copy.removeParameter(RESET_ON_LOGOUT);
597
+ }
598
+ if (copy.hasParameter(RESET_ON_DISCONNECT)) {
599
+ pSession->setResetOnDisconnect(copy.getParameter(RESET_ON_DISCONNECT) != "0");
600
+ copy.removeParameter(RESET_ON_DISCONNECT);
601
+ }
602
+ if (copy.hasParameter(REFRESH_ON_LOGON)) {
603
+ pSession->setRefreshOnLogon(copy.getParameter(REFRESH_ON_LOGON) != "0");
604
+ copy.removeParameter(REFRESH_ON_LOGON);
605
+ }
606
+ if (copy.hasParameter(MILLISECONDS_IN_TIMESTAMP)) {
607
+ pSession->setMillisecondsInTimeStamp(copy.getParameter(MILLISECONDS_IN_TIMESTAMP) != "0");
608
+ copy.removeParameter(MILLISECONDS_IN_TIMESTAMP);
609
+ }
610
+ if (copy.hasParameter(PERSIST_MESSAGES)) {
611
+ pSession->setPersistMessages(copy.getParameter(PERSIST_MESSAGES) != "0");
612
+ copy.removeParameter(PERSIST_MESSAGES);
613
+ }
614
+ if (copy.hasParameter(SEND_NEXT_EXPECTED_MSG_SEQ_NUM)) {
615
+ pSession->setSendNextExpectedMsgSeqNum(copy.getParameter(SEND_NEXT_EXPECTED_MSG_SEQ_NUM) != "0");
616
+ copy.removeParameter(SEND_NEXT_EXPECTED_MSG_SEQ_NUM);
617
+ }
618
+
619
+ if (url != copy.toString()) {
620
+ h << "<META http-equiv='refresh' content=0;URL='" << copy.toString() << "'>";
621
+ }
622
+
623
+ TABLE table(b);
624
+ table.border(1).cellspacing(2).width(100).text();
625
+
626
+ {
627
+ CAPTION caption(b);
628
+ caption.text();
629
+ EM em(b);
630
+ em.text();
631
+ b << sessionID;
632
+ {
633
+ HR hr(b);
634
+ hr.text();
635
+ }
636
+ {
637
+ b << NBSP;
638
+ A a(b);
639
+ a.href("/resetSession" + copy.getParameterString()).text("RESET");
640
+ }
641
+ {
642
+ b << NBSP;
643
+ A a(b);
644
+ a.href("/refreshSession" + copy.getParameterString()).text("REFRESH");
645
+ }
646
+ }
647
+
648
+ showRow(b, "Enabled", pSession->isEnabled(), url);
649
+ showRow(b, "ConnectionType", std::string(pSession->isInitiator() ? "initiator" : "acceptor"));
650
+ showRow(b, "SessionTime", pSession->isSessionTime(UtcTimeStamp::now()));
651
+ showRow(b, "Logged On", pSession->isLoggedOn());
652
+ showRow(b, "Next Incoming", (int)pSession->getExpectedTargetNum(), url);
653
+ showRow(b, "Next Outgoing", (int)pSession->getExpectedSenderNum(), url);
654
+ showRow(b, SEND_REDUNDANT_RESENDREQUESTS, pSession->getSendRedundantResendRequests(), url);
655
+ showRow(b, CHECK_COMPID, pSession->getCheckCompId(), url);
656
+ showRow(b, CHECK_LATENCY, pSession->getCheckLatency(), url);
657
+ showRow(b, MAX_LATENCY, pSession->getMaxLatency(), url);
658
+ showRow(b, LOGON_TIMEOUT, pSession->getLogonTimeout(), url);
659
+ showRow(b, LOGOUT_TIMEOUT, pSession->getLogoutTimeout(), url);
660
+ showRow(b, RESET_ON_LOGON, pSession->getResetOnLogon(), url);
661
+ showRow(b, RESET_ON_LOGOUT, pSession->getResetOnLogout(), url);
662
+ showRow(b, RESET_ON_DISCONNECT, pSession->getResetOnDisconnect(), url);
663
+ showRow(b, REFRESH_ON_LOGON, pSession->getRefreshOnLogon(), url);
664
+ showRow(b, MILLISECONDS_IN_TIMESTAMP, pSession->getMillisecondsInTimeStamp(), url);
665
+ showRow(b, PERSIST_MESSAGES, pSession->getPersistMessages(), url);
666
+ showRow(b, SEND_NEXT_EXPECTED_MSG_SEQ_NUM, pSession->getSendNextExpectedMsgSeqNum(), url);
667
+ } catch (std::exception &e) {
668
+ b << e.what();
669
+ }
670
+ }
671
+
672
+ void HttpConnection::processResetSession(const HttpMessage &request, std::stringstream &h, std::stringstream &b) {
673
+ try {
674
+ HttpMessage copy = request;
675
+ std::string beginString = request.getParameter("BeginString");
676
+ std::string senderCompID = request.getParameter("SenderCompID");
677
+ std::string targetCompID = request.getParameter("TargetCompID");
678
+ std::string sessionQualifier;
679
+ if (copy.hasParameter("SessionQualifier")) {
680
+ sessionQualifier = copy.getParameter("SessionQualifier");
681
+ }
682
+
683
+ SessionID sessionID(beginString, senderCompID, targetCompID, sessionQualifier);
684
+ Session *pSession = Session::lookupSession(sessionID);
685
+ if (pSession == 0) {
686
+ throw SessionNotFound();
687
+ }
688
+
689
+ std::string sessionUrl = "/session" + request.getParameterString();
690
+
691
+ bool confirm = false;
692
+ if (copy.hasParameter("confirm") && copy.getParameter("confirm") != "0") {
693
+ confirm = true;
694
+ pSession->reset();
695
+ copy.removeParameter("confirm");
696
+ }
697
+
698
+ if (confirm) {
699
+ h << "<META http-equiv='refresh' content=2;URL='" << "/session" << copy.getParameterString() << "'>";
700
+ CENTER center(b);
701
+ center.text();
702
+ H2 h2(b);
703
+ h2.text();
704
+ {
705
+ A a(b);
706
+ a.href("/session" + copy.getParameterString()).text(sessionID.toString());
707
+ }
708
+ b << " has been reset";
709
+ } else {
710
+ {
711
+ CENTER center(b);
712
+ center.text();
713
+ H2 h2(b);
714
+ h2.text();
715
+ b << "Are you sure you want to reset session ";
716
+ {
717
+ A a(b);
718
+ a.href(sessionUrl + request.getParameterString()).text(sessionID.toString());
719
+ }
720
+ b << "?";
721
+ }
722
+ {
723
+ CENTER center(b);
724
+ center.text();
725
+ b << "[";
726
+ {
727
+ A a(b);
728
+ a.href(request.toString() + "&confirm=1").text("YES, reset session");
729
+ }
730
+ b << "]" << NBSP << "[";
731
+ {
732
+ A a(b);
733
+ a.href(sessionUrl).text("NO, do not reset session");
734
+ }
735
+ b << "]";
736
+ }
737
+ }
738
+ } catch (std::exception &e) {
739
+ b << e.what();
740
+ }
741
+ }
742
+
743
+ void HttpConnection::processRefreshSession(const HttpMessage &request, std::stringstream &h, std::stringstream &b) {
744
+ try {
745
+ HttpMessage copy = request;
746
+ std::string beginString = request.getParameter("BeginString");
747
+ std::string senderCompID = request.getParameter("SenderCompID");
748
+ std::string targetCompID = request.getParameter("TargetCompID");
749
+ std::string sessionQualifier;
750
+ if (copy.hasParameter("SessionQualifier")) {
751
+ sessionQualifier = copy.getParameter("SessionQualifier");
752
+ }
753
+
754
+ SessionID sessionID(beginString, senderCompID, targetCompID, sessionQualifier);
755
+ Session *pSession = Session::lookupSession(sessionID);
756
+ if (pSession == 0) {
757
+ throw SessionNotFound();
758
+ }
759
+
760
+ std::string sessionUrl = "/session" + request.getParameterString();
761
+
762
+ bool confirm = false;
763
+ if (copy.hasParameter("confirm") && copy.getParameter("confirm") != "0") {
764
+ confirm = true;
765
+ pSession->refresh();
766
+ copy.removeParameter("confirm");
767
+ }
768
+
769
+ if (confirm) {
770
+ h << "<META http-equiv='refresh' content=2;URL='" << "/session" << copy.getParameterString() << "'>";
771
+ CENTER center(b);
772
+ center.text();
773
+ H2 h2(b);
774
+ h2.text();
775
+ {
776
+ A a(b);
777
+ a.href("/session" + copy.getParameterString()).text(sessionID.toString());
778
+ }
779
+ b << " has been refreshed";
780
+ } else {
781
+ {
782
+ CENTER center(b);
783
+ center.text();
784
+ H2 h2(b);
785
+ h2.text();
786
+ b << "Are you sure you want to refresh session ";
787
+ {
788
+ A a(b);
789
+ a.href(sessionUrl + request.getParameterString()).text(sessionID.toString());
790
+ }
791
+ b << "?";
792
+ }
793
+ {
794
+ CENTER center(b);
795
+ center.text();
796
+ b << "[";
797
+ {
798
+ A a(b);
799
+ a.href(request.toString() + "&confirm=1").text("YES, refresh session");
800
+ }
801
+ b << "]" << NBSP << "[";
802
+ {
803
+ A a(b);
804
+ a.href(sessionUrl).text("NO, do not refresh session");
805
+ }
806
+ b << "]";
807
+ }
808
+ }
809
+ } catch (std::exception &e) {
810
+ b << e.what();
811
+ }
812
+ }
813
+
814
+ void HttpConnection::showRow(std::stringstream &s, const std::string &name, bool value, const std::string &url) {
815
+ {
816
+ TR tr(s);
817
+ tr.text();
818
+ {
819
+ TD td(s);
820
+ td.text(name);
821
+ }
822
+ {
823
+ TD td(s);
824
+ td.text(value ? "yes" : "no");
825
+ }
826
+ {
827
+ TD td(s);
828
+ td.text();
829
+ CENTER center(s);
830
+ center.text();
831
+ if (url.size()) {
832
+ std::stringstream href;
833
+ href << url << "&" << name << "=" << !value;
834
+ A a(s);
835
+ a.href(href.str()).text("toggle");
836
+ }
837
+ }
838
+ }
839
+ }
840
+
841
+ void HttpConnection::showRow(
842
+ std::stringstream &s,
843
+ const std::string &name,
844
+ const std::string &value,
845
+ const std::string &url) {
846
+ {
847
+ TR tr(s);
848
+ tr.text();
849
+ {
850
+ TD td(s);
851
+ td.text(name);
852
+ }
853
+ {
854
+ TD td(s);
855
+ td.text(value);
856
+ }
857
+ {
858
+ TD td(s);
859
+ td.text();
860
+ CENTER center(s);
861
+ center.text();
862
+ }
863
+ }
864
+ }
865
+
866
+ void HttpConnection::showRow(std::stringstream &s, const std::string &name, int value, const std::string &url) {
867
+ {
868
+ TR tr(s);
869
+ tr.text();
870
+ {
871
+ TD td(s);
872
+ td.text(name);
873
+ }
874
+ {
875
+ TD td(s);
876
+ td.text(value);
877
+ }
878
+ {
879
+ TD td(s);
880
+ td.text();
881
+ CENTER center(s);
882
+ center.text();
883
+ {
884
+ std::stringstream href;
885
+ href << url << "&" << name << "=" << value - 10;
886
+ A a(s);
887
+ a.href(href.str()).text("<<");
888
+ }
889
+ s << NBSP;
890
+ {
891
+ std::stringstream href;
892
+ href << url << "&" << name << "=" << value - 1;
893
+ A a(s);
894
+ a.href(href.str()).text("<");
895
+ }
896
+ s << NBSP << "|" << NBSP;
897
+ {
898
+ std::stringstream href;
899
+ href << url << "&" << name << "=" << value + 1;
900
+ A a(s);
901
+ a.href(href.str()).text(">");
902
+ }
903
+ s << NBSP;
904
+ {
905
+ std::stringstream href;
906
+ href << url << "&" << name << "=" << value + 10;
907
+ A a(s);
908
+ a.href(href.str()).text(">>");
909
+ }
910
+ }
911
+ }
912
+ }
913
+
914
+ } // namespace FIX