1 #include <samchon/protocol/service/Client.hpp> 2 # include <samchon/protocol/service/Server.hpp> 3 # include <samchon/protocol/service/User.hpp> 4 # include <samchon/protocol/service/Service.hpp> 7 #include <boost/asio.hpp> 8 #include <boost/bind.hpp> 10 #include <samchon/library/SQLi.hpp> 11 #include <samchon/library/SQLStatement.hpp> 12 #include <samchon/library/XML.hpp> 13 #include <samchon/library/Semaphore.hpp> 15 #include <samchon/protocol/Invoke.hpp> 69 string &msg = invoke->toXML()->toString();
70 boost::system::error_code error;
72 header.push_back(129);
77 else if(header.size() <= 65535)
79 header.push_back(126);
84 header.push_back(127);
88 unique_lock<mutex> uk(*
sendMtx);
89 socket->write_some(boost::asio::buffer(header), error);
90 socket->write_some(boost::asio::buffer(msg), error);
96 std::string &listener = invoke->getListener();
98 if (listener ==
"notifyService")
100 std::string &name = invoke->at(0)->getValue<
string>();
104 else if (listener ==
"login" || listener ==
"join" || listener ==
"logout")
112 thread([
this, invoke]()
135 satisfactory =
false;
144 shared_ptr<Invoke> replyInvoke(
new Invoke(
"notifyAuthority"));
145 replyInvoke->emplace_back(
new InvokeParameter(
"authority", authority) );
146 replyInvoke->emplace_back(
new InvokeParameter(
"satisfactory", satisfactory) );
virtual void replyData(std::shared_ptr< Invoke >) override
Reply a message.
virtual void replyData(std::shared_ptr< Invoke >)
Reply a message.
virtual auto REQUIRE_AUTHORITY() const -> int=NULL
Required authority to access the service.
void sendData(std::shared_ptr< Invoke >)
Send Invoke message to (physical) client.
auto getSemaphore() const -> library::Semaphore *
Get semaphore.
auto getNo() const -> size_t
Get no.
auto getAuthority() const -> int
Get authority of user.
User containing Client(s) with session-id.
void writeReversely(const T &val)
Write a data.
Unique acquire from a Semaphore.
void replyData(std::shared_ptr< Invoke >)
Reply Invoke message from (physical) client.
void constructService(const std::string &)
Construct Service.
std::mutex * sendMtx
A mutex for sending message.
Package of cloud service as a server.
Package of network protocol and libraries.
size_t no
A sequence number of the Client in an User.
An interface for a client.
auto getUser() const -> User *
Get User.
Standard message of network I/O.
Socket * socket
Socket for network I/O.
User * user
An User of the Client.
Service * service
A Service belongs to the Client.
A parameter of an Invoke.
A keeper blocking destrunction of User and Client.
virtual auto createService(const std::string &) -> Service *=0
Factory method of Service.
std::string name
A name represents a Service.
Top level namespace of products built from samchon.
auto getService() const -> Service *
Get Service.