Pol  Revision:4b29d2b
auxclient.h
Go to the documentation of this file.
1 /*
2  * auxclient.h
3  *
4  * Created on: Nov 22, 2011
5  * Author: kevin
6  */
7 
8 #ifndef AUXCLIENT_H_
9 #define AUXCLIENT_H_
10 
11 
12 #ifndef BSCRIPT_BOBJECT_H
13 #include "../../bscript/bobject.h"
14 #endif
15 
16 #include <atomic>
17 #include <string>
18 #include <vector>
19 
20 #include "../../clib/compilerspecifics.h"
21 #include "../../clib/refptr.h"
22 #include "../../clib/socketsvc.h"
23 #include "../../clib/weakptr.h"
24 #include "../scrdef.h"
25 #include "../uoexec.h"
26 
27 namespace Pol
28 {
29 namespace Bscript
30 {
31 class Executor;
32 } // namespace Bscript
33 namespace Clib
34 {
35 class Socket;
36 } // namespace Clib
37 namespace Core
38 {
39 class UOExecutor;
40 } // namespace Core
41 } // namespace Pol
42 struct sockaddr;
43 
44 namespace Pol
45 {
46 namespace Plib
47 {
48 class Package;
49 };
50 namespace Clib
51 {
52 class ConfigElem;
53 };
54 
55 namespace Network
56 {
57 class AuxClientThread;
58 
60 {
61 public:
62  AuxConnection( AuxClientThread* auxclientthread, std::string ip )
63  : Bscript::BObjectImp( Bscript::BObjectImp::OTUnknown ),
64  _auxclientthread( auxclientthread ),
65  _ip( ip )
66  {
67  }
68 
69  virtual Bscript::BObjectImp* copy() const POL_OVERRIDE;
70  virtual bool isTrue() const POL_OVERRIDE;
71  virtual std::string getStringRep() const POL_OVERRIDE;
72  virtual size_t sizeEstimate() const POL_OVERRIDE;
73 
74  virtual Bscript::BObjectImp* call_method( const char* methodname,
76  virtual Bscript::BObjectRef get_member( const char* membername ) POL_OVERRIDE;
77 
78  void disconnect();
79 
80 private:
82  std::string _ip;
83 };
84 
86 {
87 public:
88  AuxService( const Plib::Package* pkg, Clib::ConfigElem& elem );
89  void run();
90  size_t estimateSize() const;
91 
92  const Core::ScriptDef& scriptdef() const { return _scriptdef; }
93  std::vector<unsigned int> _aux_ip_match;
94  std::vector<unsigned int> _aux_ip_match_mask;
95 
96 private:
99  unsigned short _port;
100 };
101 
103 {
104 public:
105  AuxClientThread( AuxService* auxsvc, Clib::SocketListener& listener );
107  bool assume_string );
108  virtual void run() POL_OVERRIDE;
109  void transmit( const Bscript::BObjectImp* imp );
110  Bscript::BObjectImp* get_ip();
111 
112 private:
113  bool init();
114  bool ipAllowed( sockaddr MyPeer );
115  void transmit( const std::string& msg );
122  std::atomic<int> _transmit_counter;
123 };
124 }
125 }
126 
127 #endif /* AUXCLIENT_H_ */
Bscript::BObjectImp * _params
Definition: auxclient.h:120
#define POL_OVERRIDE
AuxClientThread * _auxclientthread
Definition: auxclient.h:81
AuxConnection(AuxClientThread *auxclientthread, std::string ip)
Definition: auxclient.h:62
std::vector< unsigned int > _aux_ip_match
Definition: auxclient.h:93
Core::ScriptDef _scriptdef
Definition: auxclient.h:119
void transmit(Client *client, const void *data, int len)
Definition: clientio.cpp:291
std::vector< unsigned int > _aux_ip_match_mask
Definition: auxclient.h:94
weak_ptr< Core::UOExecutor > _uoexec
Definition: auxclient.h:118
const Plib::Package * _pkg
Definition: auxclient.h:97
ref_ptr< AuxConnection > _auxconnection
Definition: auxclient.h:117
Definition: refptr.h:65
std::atomic< int > _transmit_counter
Definition: auxclient.h:122
const Core::ScriptDef & scriptdef() const
Definition: auxclient.h:92
Core::ScriptDef _scriptdef
Definition: auxclient.h:98
unsigned short _port
Definition: auxclient.h:99
bool run(int argc, char **argv)
Definition: berror.cpp:12