plebble
peer_t.h
Go to the documentation of this file.
1 /*
2 -------------------------------------------------------------------------------
3  PLEBBLE
4 -------------------------------------------------------------------------------
5  Copyright (C) 2019-2020 KATLAS Technology. (http://katlastechnology.com)
6  Copyright (C) 2017-2020 Marcos Mayorga. (mm@mm-studios.com)
7 
8  This file is part of our Plebble(R) Platform.
9 
10  The code below cannot be copied, used for any purpose other than the one
11  agreed and/or distributed without the express permission of
12  KATLAS Technology.
13 -------------------------------------------------------------------------------
14 
15 
16 */
17 #ifndef USGOV_2d8af251450aa79ce1d82cd9d9330072930013905de9945ca29228083ef3eee4
18 #define USGOV_2d8af251450aa79ce1d82cd9d9330072930013905de9945ca29228083ef3eee4
19 
20 #include "client.h"
21 #include <atomic>
22 
23 namespace us { namespace gov {
24 namespace socket {
25  using namespace std;
26  struct daemon;
27 
28  struct peer_t: client {
29  typedef client b;
30 
31  constexpr static chrono::seconds stall{5s};
32  static const char* finished_reason_1;
33  static const char* finished_reason_2;
34 
35  peer_t();
36  peer_t(int sock);
37  peer_t(const peer_t&)=delete;
38  peer_t& operator = (const peer_t&)=delete;
39  ~peer_t() override;
40  void dump_all(const string& prefix, ostream& os) const override;
42  bool stalled_datagram() const;
44  void dump(const string& prefix, ostream& os) const;
45  virtual void on_peer_disconnected(const string& reason);
46 
47  datagram* curd{nullptr};
48  mutable mutex mx_curd;
49  };
50 }
51 }}
52 
53 #endif
54 
us::gov::socket::peer_t::peer_t
peer_t(const peer_t &)=delete
us::gov::socket::peer_t::peer_t
peer_t(int sock)
us::gov::socket::client.pair
Definition: client.cs:143
us::gov::socket::client
Definition: client.h:44
us
Definition: daemon.h:22
us::gov::socket::peer_t::dump
void dump(const string &prefix, ostream &os) const
us::gov::socket::peer_t::finished_reason_2
static const char * finished_reason_2
Definition: peer_t.h:33
us::gov::socket::datagram
Definition: datagram.h:44
us::gov::socket::peer_t::process_work
bool process_work(datagram *d)
us::gov::auth::daemon
id::daemon daemon
Definition: daemon.h:25
us::gov::socket::peer_t::~peer_t
~peer_t() override
us::gov::socket::peer_t::stalled_datagram
bool stalled_datagram() const
us::gov::socket::peer_t
Definition: peer_t.h:28
std
Definition: app.h:380
us::gov::socket::peer_t::mx_curd
mutex mx_curd
Definition: peer_t.h:48
us::gov::socket::peer_t::peer_t
peer_t()
us::gov::socket::peer_t::dump_all
void dump_all(const string &prefix, ostream &os) const override
us::gov::socket::peer_t::security_level
pair< security_level_t, string > security_level() const override
us::gov::socket::peer_t::finished_reason_1
static const char * finished_reason_1
Definition: peer_t.h:32
client.h
us::gov::socket::peer_t::on_peer_disconnected
virtual void on_peer_disconnected(const string &reason)
us::gov::socket::peer_t::b
client b
Definition: peer_t.h:29