libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
connectivity_policy.hpp
Go to the documentation of this file.
1
#
ifndef
ISIMUD_EXCHANGES_MIT_common_connectivity_policy_hpp
2
#
define
ISIMUD_EXCHANGES_MIT_common_connectivity_policy_hpp
3
4
/******************************************************************************
5
** Copyright © 2015 by J.M.McGuiness, isimud@hussar.me.uk
6
**
7
** This library is free software; you can redistribute it and/or
8
** modify it under the terms of the GNU Lesser General Public
9
** License as published by the Free Software Foundation; either
10
** version 2.1 of the License, or (at your option) any later version.
11
**
12
** This library is distributed in the hope that it will be useful,
13
** but WITHOUT ANY WARRANTY; without even the implied warranty of
14
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
** Lesser General Public License for more details.
16
**
17
** You should have received a copy of the GNU Lesser General Public
18
** License along with this library; if not, write to the Free Software
19
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
*/
21
22
#
include
"messages.hpp"
23
#
include
"../../common/server_heartbeats.hpp"
24
25
#
include
<
boost
/
asio
/
ip
/
address
.
hpp
>
26
#
include
<
boost
/
asio
/
ip
/
tcp
.
hpp
>
27
#
include
<
boost
/
exception_ptr
.
hpp
>
28
29
#
include
<
atomic
>
30
#
include
<
chrono
>
31
#
include
<
thread
>
32
33
namespace
isimud
{
namespace
ISIMUD_VER_NAMESPACE
{
namespace
exchanges {
namespace
MIT
{
namespace
common
{
34
35
/// An implementation of the connectivity policy for the MIT protocol.
36
/**
37
From section 4.4 "Connectivity Policy" of [1].
38
Note that BIT is the same, but OLSO & TRQ are unclear regarding this policy, so we'll assume it is the same.
39
[1] "MIT203 - MILLENNIUM EXCHANGE Native Trading Gateway" Issue 11.6, 17 August 2015.
40
*/
41
template
<
class
LogonT>
42
class
connectivity_policy
{
43
public
:
44
using
logon_args_t=LogonT;
45
using
endpoint_t=
std
::pair<
boost
::
asio
::
ip
::address,
unsigned
short
>;
46
struct
gateways_t
{
47
const
endpoint_t
primary_gateway
;
48
const
endpoint_t
secondary_gateway
;
49
50
constexpr
gateways_t
(endpoint_t
const
&primary, endpoint_t
const
&secondary)
noexcept
(
true
)
51
:
primary_gateway
(
primary
),
secondary_gateway
(
secondary
) {
52
}
53
gateways_t
(
gateways_t
const
&)=
default
;
54
};
55
enum
:
unsigned
{
56
max_attempts
=3
57
};
58
static
inline
constexpr
std
::
chrono
::
seconds
min_timeout
{5};
59
const
gateways_t
gateways
;
60
const
logon_args_t
logon_args
;
61
const
logoff_args_t
logoff_args
;
62
63
connectivity_policy
(
gateways_t
const
&gws, logon_args_t
const
&logon,
logoff_args_t
const
&logoff)
noexcept
(
true
);
64
65
template
<
class
ConnectFn>
66
void
operator
()(ConnectFn
const
&cnx)
const
noexcept
(
false
);
67
68
private
:
69
template
<
class
ConnectFn>
static
70
boost
::exception_ptr connection_failed(ConnectFn
const
&cnx, endpoint_t
const
&endpoint)
noexcept
(
true
);
71
};
72
73
/// Section 5.2.2 "Heartbeats" of [1]. Generate heartbeats from the containing simulator.
74
/**
75
The simulator generates heartbeats to which the client responds.
76
*/
77
template
<
class
MsgT>
78
class
server_hb_t
:
public
exchanges::common::
server_hb_t
<MsgT, 5, 3> {
79
public
:
80
using
base_t=exchanges::common::
server_hb_t
<MsgT, 5, 3>;
81
82
template
<
class
ClientCxn>
83
explicit
server_hb_t
(ClientCxn &cxn);
84
};
85
86
} } } } }
87
88
#
include
"connectivity_policy_impl.hpp"
89
90
#
endif
isimud
exchanges
MIT
common
connectivity_policy.hpp
Generated on Tue May 11 2021 17:25:46 for libjmmcg by
1.9.2