SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
CRUD_Link.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
6  */
7 
8 #pragma once
9 #include "CRUDP_Protocol.h"
11 
12 #include <ace/INET_Addr.h>
13 #include <ace/Reactor_Notification_Strategy.h>
14 #include <ace/SOCK_Dgram.h>
15 #include <ace/config-macros.h>
16 #include <stddef.h>
17 #include <chrono>
18 
19 class EventSrc;
20 
21 namespace SEGSEvents
22 {
23  class Event;
24  class Packet;
25 }
26 class CRUD_EventFactory;
27 
28 
29 class CRUDLink : public LinkBase
30 {
31 using super = LinkBase;
32 public:
33 
34 using stream_type = ACE_SOCK_Dgram;
35 using addr_type = ACE_INET_Addr;
36 using time_point = std::chrono::steady_clock::time_point;
37 using duration = std::chrono::milliseconds;
38 public:
39  CRUDLink();
40  ~CRUDLink() override;
41 
42  int open(void * = nullptr) override;
43  int handle_output( ACE_HANDLE = ACE_INVALID_HANDLE ) override;
44  void received_block(BitStream &bytes);
45  CrudP_Protocol * get_proto() { return &m_protocol; }
46  stream_type & peer() { return peer_; }
47  addr_type & peer_addr() { return m_peer_addr; }
48 
49  duration client_last_seen_packets() const;
50  duration last_sent_packets() const;
51  size_t client_packets_waiting_for_ack() const { return m_protocol.UnackedPacketCount(); }
52 protected:
53  int handle_close(ACE_HANDLE h, ACE_Reactor_Mask c) override;
54  void event_for_packet(SEGSEvents::Packet *pak_ev);
55  void packets_for_event(SEGSEvents::Event *c_ev);
56  void connection_update();
57  void connection_sent_packet();
58  EventSrc * target() { return m_target; }
59  EventSrc * net_layer() { return m_net_layer; }
60 virtual CRUD_EventFactory & factory() = 0;
61  ACE_HANDLE get_handle() const override {return peer_.get_handle();}
62 
63  ACE_Reactor_Notification_Strategy m_notifier;
71 
72 };
Definition: CRUD_Events.h:34
Definition: EventProcessor.h:14
Definition: SEGSEvent.h:35
Definition: BitStream.h:34
Definition: LinkLevelEvent.h:13
Definition: ILink.h:14
Definition: CRUDP_Protocol.h:37
Definition: CRUD_Events.h:121