OnixS C++ CBOE CFE Binary Order Entry (BOE) Handler 1.12.0
API documentation
Loading...
Searching...
No Matches
Gateway.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18 */
19#pragma once
20
21#include <OnixS/CboeCFE/Trading/BOE/Compiler.h>
22
23#if ONIXS_BATS_BOE_HAS_GATEWAY_EMULATOR
24
27
28#include <chrono>
29
30namespace OnixS {
31namespace CboeCFE {
32namespace Trading {
33namespace BOE {
34namespace Testing {
35
36
37class ONIXS_CBOE_CFE_BOE_API Gateway
38{
39public:
40 explicit Gateway(int port, const char* host = "127.0.0.1", const std::chrono::seconds& acceptTimeout = std::chrono::seconds(10),
41 const std::chrono::seconds& sendReceiveTimeout = std::chrono::seconds(10));
42
44 virtual ~Gateway();
45
47 Gateway(const Gateway&) = delete;
48 Gateway& operator=(const Gateway&) = delete;
49
51 Gateway(Gateway&&) noexcept;
52 Gateway& operator=(Gateway&&) noexcept;
53
55 void swap(Gateway&) noexcept;
56
58 const char * host() const noexcept;
59
61 int port() const noexcept;
62
65 Gateway& acceptConnection(const std::chrono::seconds& acceptTimeout = std::chrono::seconds(0));
66
68 Gateway& sendApplicationMessage(const OutgoingMessage& msg, SeqNumber seqNumber = SeqNumberTraits::InvalidValue);
69
72 template <BOE::MessageType::Enum Type>
73 MessagePtr<typename MessageTypeTraits<Type>::MessageType> receiveTypedMessage() const;
74
76 void sendHeartbeat();
77
82 LogoutRequestPtr waitUntilLogoutRequested(
83 ClientMessageListener* listener = nullptr, ClientSessionMessageListener* sessionMessageListener = nullptr);
84
89 Gateway& run(ClientMessageListener& listener);
90
95 Gateway& run(ClientMessageListener& appMsgListener, ClientSessionMessageListener& sessionMsgListener);
96
97protected:
99 bool isConnectionClosed(const std::chrono::seconds& timeout) const;
100
103 bool isConnectionClosed() const;
104
106 Gateway& close();
107
109 Gateway& disconnect();
110
112 MessageBasePtr receive() const;
113
115 MessageBasePtr receive(PacketContainer && container, MessageSize containerSize);
116
118 Gateway& sendData(const void* data, size_t size);
119
121 Gateway& sendSessionMessage(const OutgoingMessage& msg);
122
126 LoginRequestPtr receiveLoginRequest();
127
131 LogoutRequestPtr receiveLogoutRequest();
132
136 ClientHeartbeatPtr receiveClientHeartbeat();
137
141 LoginRequestPtr acceptLogin(SeqNumber clientSequence = 1);
142
146 LoginRequestPtr rejectLogin();
147
151 LogoutRequestPtr acceptLogout();
152
156 LoginRequestPtr acceptSession(SeqNumber clientSequence = 1);
157
159 void sendLogout(LogoutResponseReason::Enum reason);
160
162 void sendReplayComplete();
163
164private:
165 class Impl;
166 Impl* impl_;
167};
168
169template <BOE::MessageType::Enum Type>
170MessagePtr<typename MessageTypeTraits<Type>::MessageType> Gateway::receiveTypedMessage() const
171{
172 return cast<Type>(receive());
173}
174
175
176}}}}}
177
178#endif