SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
AuthLink.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 
11 
12 #include <ace/SOCK_Stream.h>
13 #include <ace/Thread_Mutex.h>
14 #include <ace/Reactor_Notification_Strategy.h>
15 
16 #include <memory>
17 
18 enum class AuthLinkType
19 {
20  Server = 0,
21  Client = 1
22 };
23 struct AuthLinkState;
24 // AuthLinks are created when connection is accepted.
25 // They serve as one of the primary event sources in the system, the other being Timers
26 // Whenever new bytes are received, the AuthLink tries to convert them into proper higher level Events,
27 // And posts them to g_target
28 // Each AuthLink serves as a Client's connection context
29 class AuthLink final : public LinkBase
30 {
31  using super = LinkBase;
32  using tNotifyStrategy = ACE_Reactor_Notification_Strategy;
33  friend class AuthHandler; // auth handler changes our m_state variable
34 public:
36  {
42  DISCONNECTED
43  };
44 
45  using stream_type = ACE_SOCK_Stream;
46  using addr_type = ACE_INET_Addr;
47 
48  AuthLink();
50  ~AuthLink() override;
51 
52  int open(void * = nullptr) override;
53  int handle_input (ACE_HANDLE) override;
54  int handle_output(ACE_HANDLE fd = ACE_INVALID_HANDLE) override;
55  int handle_close(ACE_HANDLE handle,ACE_Reactor_Mask close_mask) override;
56  stream_type & peer() {return m_peer;}
57  addr_type & peer_addr() {return m_peer_addr;}
58  void init_crypto(int vers,uint32_t seed);
59  ACE_HANDLE get_handle () const override {return m_peer.get_handle();}
60  eLinkStage get_link_stage() const;
61  void set_link_stage(AuthLink::eLinkStage stage);
62 protected:
63 
64  EventProcessor *m_target; // Target handler of this link
65  tNotifyStrategy m_notifier;
68  ACE_Thread_Mutex m_buffer_mutex;
69  std::unique_ptr<AuthLinkState> m_state;
70 };
71 
72 
Definition: ILink.h:14
int open(void *args=nullptr) override
Definition: EventProcessor.cpp:24
Definition: AuthLink.cpp:24
Definition: EventProcessor.h:22
Definition: AuthHandler.h:77