2 #include <samchon/API.hpp> 4 #include <boost/asio.hpp> 6 #include <samchon/library/XML.hpp> 29 std::shared_ptr<library::XML>
policy;
40 std::make_shared<library::XML>
43 "<cross-domain-policy>\n" +
44 " <allow-access-from domain='*' to-ports='*' />\n" +
45 "</cross-domain-policy>" 58 this->policy = policy;
66 boost::asio::io_service ioService;
67 boost::asio::ip::tcp::endpoint endPoint(boost::asio::ip::tcp::v4(), port);
68 boost::asio::ip::tcp::acceptor acceptor(ioService, endPoint);
72 auto socket = std::make_shared<boost::asio::ip::tcp::socket>(ioService);
73 acceptor.accept(*socket);
75 std::thread(&FlashPolicyServer::accept,
this, socket).detach();
87 void setPolicy(std::shared_ptr<library::XML> xml)
98 void accept(std::shared_ptr<boost::asio::ip::tcp::socket> socket)
100 std::string data =
"<?xml version=\"1.0\"?>\n" + policy->toString();
101 std::vector<unsigned char> piece;
102 boost::system::error_code error;
106 piece.assign(1000, NULL);
107 socket->read_some(boost::asio::buffer(piece), error);
109 boost::system::error_code error;
110 socket->write_some(boost::asio::buffer(data), error);
FlashPolicyServer(std::shared_ptr< library::XML > policy)
Construct from custom policy_.
std::shared_ptr< library::XML > policy
cross-domain-policy_
auto getPolicy() const -> std::shared_ptr< library::XML >
Get policy.
FlashPolicyServer()
Default constructor.
void open(int port=843)
Open server.
void accept(std::shared_ptr< boost::asio::ip::tcp::socket > socket)
Accept client.