Minetest  5.4.0
peerhandler.h
Go to the documentation of this file.
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #pragma once
21 
22 #include "networkprotocol.h"
23 
24 namespace con
25 {
26 
27 typedef enum
28 {
36 
37 class Peer;
38 
40 {
41 public:
42  PeerHandler() = default;
43 
44  virtual ~PeerHandler() = default;
45 
46  /*
47  This is called after the Peer has been inserted into the
48  Connection's peer container.
49  */
50  virtual void peerAdded(Peer *peer) = 0;
51 
52  /*
53  This is called before the Peer has been removed from the
54  Connection's peer container.
55  */
56  virtual void deletingPeer(Peer *peer, bool timeout) = 0;
57 };
58 
59 enum PeerChangeType : u8
60 {
63 };
64 
65 struct PeerChange
66 {
67  PeerChange(PeerChangeType t, session_t _peer_id, bool _timeout) :
68  type(t), peer_id(_peer_id), timeout(_timeout)
69  {
70  }
71  PeerChange() = delete;
72 
75  bool timeout;
76 };
77 }
Definition: peerhandler.h:40
virtual ~PeerHandler()=default
virtual void deletingPeer(Peer *peer, bool timeout)=0
PeerHandler()=default
virtual void peerAdded(Peer *peer)=0
Definition: connection.h:523
Definition: client.h:64
PeerChangeType
Definition: peerhandler.h:60
@ PEER_REMOVED
Definition: peerhandler.h:62
@ PEER_ADDED
Definition: peerhandler.h:61
rtt_stat_type
Definition: peerhandler.h:28
@ MAX_RTT
Definition: peerhandler.h:30
@ MAX_JITTER
Definition: peerhandler.h:33
@ AVG_JITTER
Definition: peerhandler.h:34
@ MIN_JITTER
Definition: peerhandler.h:32
@ MIN_RTT
Definition: peerhandler.h:29
@ AVG_RTT
Definition: peerhandler.h:31
u16 session_t
Definition: networkprotocol.h:234
Definition: peerhandler.h:66
session_t peer_id
Definition: peerhandler.h:74
PeerChangeType type
Definition: peerhandler.h:73
PeerChange()=delete
PeerChange(PeerChangeType t, session_t _peer_id, bool _timeout)
Definition: peerhandler.h:67
bool timeout
Definition: peerhandler.h:75