SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Auth.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2018 SEGS Team (see Authors.txt)
5  * This software is licensed! (See License.txt for details)
6  */
7 
8 #pragma once
9 
10 #include <ace/Connector.h>
11 #include <ace/Svc_Handler.h>
12 #include <ace/SOCK_Connector.h>
13 #include <ace/SOCK_Stream.h>
14 #include <ace/Reactor_Notification_Strategy.h>
15 #include <string>
16 
17 class AuthPacket;
18 class AuthConnection;
19 class pktAuthVersion;
20 class AuthObserver;
21 class AuthInterface;
22 class Auth_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM,ACE_NULL_SYNCH>
23 {
24  typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> PARENT;
25  public:
26  Auth_Handler():notifier_ (0, this, ACE_Event_Handler::WRITE_MASK),m_observer(0)
27  {
28  ACE_ASSERT(!"Auth_Handler should not be automatically instantiated!");
29  }
30  Auth_Handler(AuthObserver *observer):notifier_ (0, this, ACE_Event_Handler::WRITE_MASK),m_observer(observer)
31  {}
32 
33  virtual int open (void * = 0);
34 
35  // Called when input is available from the client.
36  virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE);
37 
38  // Called when output is possible.
39  virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE);
40 
41  // Called when a timer expires.
42  virtual int handle_timeout (const ACE_Time_Value &current_time,
43  const void *act = 0);
44 
45  private:
46  enum { ITERATIONS = 5 };
47  int iterations_;
48  ACE_Reactor_Notification_Strategy notifier_;
49  AuthConnection *m_conn;
50  AuthObserver *m_observer;
51 };
52 
53 class Auth_Client_Connector : public ACE_Connector<Auth_Handler,ACE_SOCK_CONNECTOR>
54 {
55  typedef ACE_Connector<Auth_Handler,ACE_SOCK_CONNECTOR> PARENT;
56  public:
57  // Initialization
60 
61  private:
62  ACE_INET_Addr remote_addr_; // this is where the auth server lives
63 };
64 
65 // High level representation of Client-Server language
67 {
68  public:
69  virtual void notify_connection_created(AuthInterface *conn)=0;
70  virtual void notify_connected()=0;
71  virtual void notify_disconnected()=0;
72  virtual void notify_raw_data(char *dat,size_t sz)=0;
73  virtual void notify_packet(pktAuthVersion *)=0;
74 };
75 
76 class AuthInterface // interface wrapper to Auth server functions
77 {
78  AuthConnection *m_conn;
79  public:
80  AuthInterface(AuthConnection *); // this is connection this interface sends requests on.
81  void login(const std::string & login,const std::string & passw);
82 };
virtual int handle_timeout(const ACE_Time_Value &current_time, const void *act=0)
Definition: Auth.cpp:55
Definition: Auth.h:76
virtual void notify_raw_data(char *dat, size_t sz)=0
void login(const std::string &login, const std::string &passw)
Definition: Auth.cpp:101
virtual void notify_disconnected()=0
Definition: Auth.h:53
~Auth_Client_Connector(void)
Definition: Auth.h:59
Auth_Handler()
Definition: Auth.h:26
virtual int open(void *=0)
Definition: Auth.cpp:19
virtual int handle_output(ACE_HANDLE fd=ACE_INVALID_HANDLE)
Definition: Auth.cpp:71
virtual void notify_connected()=0
This will allow the observ to send commands to the AuthServer.
virtual int handle_input(ACE_HANDLE fd=ACE_INVALID_HANDLE)
Definition: Auth.cpp:37
virtual void notify_connection_created(AuthInterface *conn)=0
Auth_Client_Connector(void)
Definition: Auth.h:58
AuthInterface(AuthConnection *)
Definition: Auth.cpp:96
Definition: Auth.h:66
Definition: Auth.h:22
virtual void notify_packet(pktAuthVersion *)=0
Auth_Handler(AuthObserver *observer)
Definition: Auth.h:30