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_BATSBOE_common_connectivity_policy_hpp
2
#
define
ISIMUD_EXCHANGES_BATSBOE_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
BATSBOE
{
namespace
common
{
34
35
/// An implementation of the connectivity policy for the BATSBOE protocol.
36
/**
37
From section 2.2 "Login, Replay & Sequencing" of the EU & US specifications.
38
*/
39
template
<
class
LogonT>
40
class
connectivity_policy
{
41
public
:
42
using
logon_args_t=LogonT;
43
using
endpoint_t=
std
::pair<
boost
::
asio
::
ip
::address,
unsigned
short
>;
44
struct
gateways_t
{
45
endpoint_t
primary_gateway
;
46
47
explicit
gateways_t
(endpoint_t
const
&primary)
noexcept
(
true
)
48
:
primary_gateway
(
primary
) {
49
}
50
gateways_t
(
gateways_t
const
&gws)
noexcept
(
true
)
51
:
primary_gateway
(
gws
.
primary_gateway
) {
52
}
53
};
54
enum
:
unsigned
{
55
max_attempts
=3
56
};
57
static
inline
constexpr
std
::
chrono
::
seconds
min_timeout
{5};
58
const
gateways_t
gateways
;
59
const
logon_args_t
logon_args
;
60
const
logoff_args_t
logoff_args
;
61
62
explicit
connectivity_policy
(
gateways_t
const
&gws, logon_args_t
const
&logon,
logoff_args_t
const
&logoff)
noexcept
(
true
);
63
64
template
<
class
ConnectFn>
65
void
operator
()(ConnectFn
const
&cnx)
const
noexcept
(
false
);
66
67
private
:
68
template
<
class
ConnectFn>
static
69
boost
::exception_ptr connection_failed(ConnectFn
const
&cnx, endpoint_t
const
&endpoint)
noexcept
(
true
);
70
};
71
72
/// Section 2.4 "Heartbeats" of [1]. Generate heartbeats from the containing simulator.
73
/**
74
The simulator generates heartbeats to which the client responds.
75
*/
76
template
<
class
MsgT>
77
class
server_hb_t
:
public
exchanges::common::
server_hb_t
<MsgT, 5, 1> {
78
public
:
79
using
base_t=exchanges::common::
server_hb_t
<MsgT, 5, 1>;
80
81
template
<
class
ClientCxn>
82
explicit
server_hb_t
(ClientCxn &cxn);
83
};
84
85
} } } } }
86
87
#
include
"connectivity_policy_impl.hpp"
88
89
#
endif
isimud
exchanges
BATSBOE
common
connectivity_policy.hpp
Generated on Tue May 11 2021 17:22:15 for libjmmcg by
1.9.2