Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::ServerLoader Class Reference

#include <ServerLoader.hpp>

Public Member Functions

 ServerLoader ()
 
 ~ServerLoader ()
 
OTServergetServer ()
 
int getPort () const
 

Detailed Description

Definition at line 147 of file ServerLoader.hpp.

Constructor & Destructor Documentation

opentxs::ServerLoader::ServerLoader ( )
inline

Definition at line 150 of file ServerLoader.hpp.

151  : server_(nullptr)
152  {
153 // This is optional! (I, of course, am using it in this test app...)
154 #if defined(OT_SIGNAL_HANDLING)
156 #endif
157  // I instantiate this here (instead of globally) so that I am
158  // assured that any globals and other
159  // setup is already done before we instantiate the server object
160  // itself.
161  OT_ASSERT_MSG(nullptr == server_,
162  "server main(): ASSERT: nullptr == server_.");
163  server_ = new OTServer;
164 
166  nullptr != server_,
167  "server main(): ASSERT: Unable to instantiate OT server.\n");
168 
169  {
170  bool setupPathsSuccess = false;
172  OT_FAIL;
173  }
174  else {
175  setupPathsSuccess = true;
176  }
177  OT_ASSERT_MSG(setupPathsSuccess,
178  "main(): Assert failed: Failed to set OT Path");
179 
181  OT_FAIL;
182  }
183  }
184  OTCrypto::It()->Init();
185 
186  // OTServer::Init loads up server's nym so it can decrypt messages sent
187  // in envelopes. It also does various other initialization work.
188  //
189  // NOTE: Envelopes prove that ONLY someone who actually had the server
190  // contract, and had loaded it into his wallet, could ever connect to
191  // the server or communicate with it. And if that person is following
192  // the contract, there is only one server he can connect to, and one
193  // key he can use to talk to it.
194  //
195  // Keys, etc are loaded here. Assumes main path is set!
196  server_->Init();
197 
198  // A heartbeat for recurring transactions, such as markets, payment
199  // plans, and smart contracts.
200  server_->ActivateCron();
201  }
static EXPORT OTCrypto * It()
Definition: OTCrypto.cpp:630
#define SERVER_CONFIG_KEY
static EXPORT bool IsInitialized()
static EXPORT bool Init(const OTString &strThreadContext)
EXPORT void Init(bool readOnly=false)
Definition: OTServer.cpp:397
static EXPORT void SetupSignalHandler()
Definition: OTLog.cpp:1315
EXPORT void ActivateCron()
Definition: OTServer.cpp:300
#define OT_ASSERT_MSG(x, s)
Definition: Assert.hpp:155
#define OT_FAIL
Definition: Assert.hpp:139
EXPORT void Init() const
Definition: OTCrypto.cpp:646
opentxs::ServerLoader::~ServerLoader ( )
inline

Definition at line 203 of file ServerLoader.hpp.

204  {
205  OTLog::vOutput(0, "\n\n Shutting down and cleaning up.\n");
206 
207  if (server_) {
208  delete server_;
209  server_ = nullptr;
210  }
212  OTCrypto::It()->Cleanup();
213  }
static EXPORT OTCrypto * It()
Definition: OTCrypto.cpp:630
static EXPORT void Cleanup()
EXPORT void Cleanup() const
Definition: OTCrypto.cpp:678
static EXPORT void vOutput(int32_t nVerbosity, const char *szOutput,...)
Definition: OTLog.cpp:768

Member Function Documentation

int opentxs::ServerLoader::getPort ( ) const
inline

Definition at line 220 of file ServerLoader.hpp.

221  {
222  // We're going to listen on the same port that is listed in our server
223  // contract. The hostname of this server, according to its own contract.
224  OTString hostname;
225  int port = 0;
226  bool connectInfo = server_->GetConnectInfo(hostname, port);
227 
228  OT_ASSERT_MSG(connectInfo,
229  "server main: Unable to find my own connect "
230  "info (which SHOULD be in my server contract, "
231  "BTW.) Perhaps you failed trying to open that "
232  "contract? Have you tried the test password? "
233  "(\"test\")\n");
234  return port;
235  }
bool GetConnectInfo(OTString &hostname, int32_t &port) const
Definition: OTServer.cpp:849
#define OT_ASSERT_MSG(x, s)
Definition: Assert.hpp:155
OTServer* opentxs::ServerLoader::getServer ( )
inline

Definition at line 215 of file ServerLoader.hpp.

216  {
217  return server_;
218  }

The documentation for this class was generated from the following file: