1 #include <samchon/protocol/service/Server.hpp> 2 # include <samchon/protocol/service/User.hpp> 3 # include <samchon/protocol/service/IPUserPair.hpp> 5 #include <boost/asio.hpp> 10 #include <samchon/SmartPointer.hpp> 11 #include <samchon/library/SQLi.hpp> 12 #include <samchon/library/Datetime.hpp> 14 #include <samchon/library/XML.hpp> 15 #include <samchon/protocol/Invoke.hpp> 16 #include <samchon/protocol/InvokeParameter.hpp> 45 auto Server::getSQLi()
const ->
SQLi*
59 return super::begin();
71 thread([
this, socket]()
74 string &ip = socket->remote_endpoint().address().to_v4().to_string();
77 if (
ipMap.has(ip) ==
false)
81 shared_ptr<IPUserPair>(
new IPUserPair(
this, ip))
84 shared_ptr<IPUserPair> pair =
ipMap.get(ip);
89 std::string &sessionID = pair->getSessionID(socket,
sequence);
94 if (sessionID.empty() ==
true)
97 if (pair->userSet.size() == 1)
104 iterator it = find(sessionID);
110 user->sessionID = sessionID;
111 user->ipPair = pair.
get();
113 pair->userSet.insert(user.
get());
114 it = insert({ sessionID, user }).first;
120 it->second->addClient(socket);
123 void Server::eraseUser(
const std::string &session)
128 if (!(
has(session) ==
true &&
get(session)->empty() ==
true))
131 User *user =
get(session).
get();
135 if (ipPair->
userSet.empty() ==
true)
138 super::erase(session);
An interface of a physical server.
auto begin() const -> const_iterator
A const iterator of begin.
Dictionary< std::shared_ptr< IPUserPair > > ipMap
Dictionary of issuer of session ID of each ip.
Relationship between IP address and User for issuing session.
auto end() const -> const_iterator
A const iterator of end.
User containing Client(s) with session-id.
virtual auto createUser() -> User *=0
Factory method of User.
std::set< const User * > userSet
User(s) belongs to the IP address.
Package of cloud service as a server.
Package of network protocol and libraries.
virtual void addClient(Socket *) override
Handling connection of a client.
std::string ip
An IP address.
A SQL interface; DBMS connector.
auto size() const -> size_t
Size of User(s).
library::SQLi * sqli
SQLi for archiving log.
auto has(const _Kty &key) const -> bool
Whether have the item or not.
size_t sequence
Sequence for issuing session ID.
auto get() const -> _Ty *
Get pointer.
Top level namespace of products built from samchon.