SmartFoxServer 2X C++ API
CryptoInitializer.h
1 // ===================================================================
2 //
3 // Description
4 // Helper class for crypting
5 //
6 // Revision history
7 // Date Description
8 // 01-May-2015 First version
9 //
10 // ===================================================================
11 #ifndef __CryptoInitializer__
12 #define __CryptoInitializer__
13 
14 #include "./Common.h"
15 #include "../SmartFox.h"
16 
17 #include <boost/shared_ptr.hpp> // Boost Asio shared pointer
18 
19 #if defined(_MSC_VER)
20 #pragma warning(disable:4786) // STL library: disable warning 4786; this warning is generated due to a Microsoft bug
21 #endif
22 #include <string> // STL library: string object
23 using namespace std; // STL library: declare the STL namespace
24 
25 namespace Sfs2X {
26  namespace Util {
27 
32  {
33  public:
34 
35  // -------------------------------------------------------------------
36  // Public methods
37  // -------------------------------------------------------------------
38 
39  CryptoInitializer(boost::shared_ptr<SmartFox> sfs);
40 
44  void Run();
45 
46  // -------------------------------------------------------------------
47  // Public members
48  // -------------------------------------------------------------------
49  static boost::shared_ptr<string> KEY_SESSION_TOKEN;
50  static boost::shared_ptr<string> TARGET_SERVLET;
51 
52  protected:
53 
54  // -------------------------------------------------------------------
55  // Protected methods
56  // -------------------------------------------------------------------
57 
58  // -------------------------------------------------------------------
59  // Protected members
60  // -------------------------------------------------------------------
61 
62  private:
63 
64  // -------------------------------------------------------------------
65  // Private methods
66  // -------------------------------------------------------------------
67  void RunHelper();
68  bool RunHelperAsync();
69  bool RunHelperSSLAsync();
70  void OnHttpResponse(boost::shared_ptr<string> rawData);
71  void OnHttpError(boost::shared_ptr<string> errorMsg);
72 
73  boost::shared_ptr<ByteArray> DecodeResponse (boost::shared_ptr<string> rawData);
74 
75  // -------------------------------------------------------------------
76  // Private members
77  // -------------------------------------------------------------------
78  boost::shared_ptr<SmartFox> sfs;
79  boost::shared_ptr<string> key; // This is the session key retrieved by RunHelperAsync/RunHelperSSLAsync that for linux compatibility is stored as local variabile instead of returned from methods
80  boost::shared_ptr<string> errorMessage; // This is the error string if it exists
81  bool useHttps;
82  };
83 
84  } // namespace Util
85 } // namespace Sfs2X
86 
87 #endif
STL namespace.
Initializer for encryption
Definition: CryptoInitializer.h:31
Definition: SmartFox.cpp:24