1 #include <samchon/protocol/service/IPUserPair.hpp> 2 # include <samchon/protocol/service/Server.hpp> 3 # include <samchon/protocol/service/User.hpp> 5 #include <boost/asio.hpp> 10 #include <samchon/library/Datetime.hpp> 11 #include <samchon/library/XML.hpp> 12 #include <samchon/protocol/Invoke.hpp> 13 #include <samchon/protocol/InvokeParameter.hpp> 25 IPUserPair::IPUserPair(
Server *server,
const string &ip)
27 this->server = server;
30 auto IPUserPair::getSessionID(Socket *socket,
size_t sequence) -> std::string
32 std::string sessionID;
36 boost::system::error_code error;
39 vector<unsigned char> piece(1000, NULL);
40 socket->read_some(boost::asio::buffer(piece), error);
45 std::string str((
char*)piece.data());
46 shared_ptr<XML> xml(
new XML(str));
48 shared_ptr<Invoke> invoke(
new Invoke());
49 invoke->construct(xml);
51 sessionID = invoke->at(0)->getValue<
string>();
55 if (sessionID.empty() ==
true || server->has(sessionID) ==
false)
58 sessionID = issueSessionID(sequence);
61 if (server->has(sessionID) ==
true)
62 throw runtime_error(
"Session ID is not unique");
67 shared_ptr<Invoke> invoke(
new Invoke(
"notifySessionID") );
70 std::string &data = invoke->toXML()->toString();
71 boost::system::error_code error;
73 socket->write_some(boost::asio::buffer(data), error);
81 auto IPUserPair::issueSessionID(
size_t sequence)
const -> std::string
83 std::string &name = server->NAME();
84 int port = server->PORT();
88 sstream << name <<
"::" 89 << hex << port <<
"::" 90 << hex << sequence <<
"::" auto toLinuxTime() const -> long long
Converts the Date to linux_time.
Package of cloud service as a server.
Package of network protocol and libraries.
A server for (cloud) service.
Standard message of network I/O.
XML is a class representing xml object.
A parameter of an Invoke.
Top level namespace of products built from samchon.