Samchon Framework for CPP  1.0.0
ExternalServer.cpp
1 #include <samchon/protocol/ExternalServer.hpp>
2 
3 #include <thread>
4 #include <samchon/library/XML.hpp>
5 
6 using namespace std;
7 using namespace samchon::library;
8 using namespace samchon::protocol;
9 
10 /* ------------------------------------------------------------------
11  CONSTRUCTORS
12 ------------------------------------------------------------------ */
13 ExternalServer::ExternalServer()
14  : super(),
16 {
17 }
18 void ExternalServer::construct(shared_ptr<XML> xml)
19 {
20  super::construct(xml);
21 
22  if(xml->hasProperty("myIP") == true)
23  this->myIP = xml->getProperty("myIP");
24  else
25  this->myIP.clear();
26 }
27 
29 {
30  this->connect();
31  this->listen();
32 }
33 
34 /* ------------------------------------------------------------------
35  GETTERS
36 ------------------------------------------------------------------ */
37 auto ExternalServer::getIP() const -> string
38 {
39  return ip;
40 }
41 auto ExternalServer::getPort() const -> int
42 {
43  return port;
44 }
45 
46 auto ExternalServer::getMyIP() const -> string
47 {
48  return myIP;
49 }
50 
51 /* ------------------------------------------------------------------
52  EXPORTERS
53 ------------------------------------------------------------------ */
54 auto ExternalServer::toXML() const -> shared_ptr<XML>
55 {
56  shared_ptr<XML> &xml = super::toXML();
57 
58  if(myIP.empty() == false)
59  xml->setProperty("myIP", myIP);
60 
61  return xml;
62 }
int port
A port number of an external system.
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the EntityGroup.
Definition: RWMutex.hpp:4
Package of libraries.
Definition: library.hpp:84
virtual void start() override
Start interaction.
std::string ip
An ip address of an external system.
Package of network protocol and libraries.
Definition: protocol.hpp:185
A network driver for an external system.
virtual void construct(std::shared_ptr< library::XML >) override
Construct data of the Entity from an XML object.
virtual auto getIP() const -> std::string override
Destinatio IP.
virtual void construct(std::shared_ptr< library::XML >) override
Construct data of the Entity from an XML object.
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the EntityGroup.
std::string myIP
A custom ip address of my system to bind.
virtual auto getPort() const -> int override
Destination port.
XML is a class representing xml object.
Definition: XML.hpp:72
virtual void listen()
Listens message from a related system.
Definition: IClient.cpp:45
virtual void connect()
Connect to a server.
virtual auto getMyIP() const -> std::string override
(optional) My IP, if you want to bind
A server connector for a physical client.