blob: 016ff50708788121cd7f5908af068064fdebf85a [file] [log] [blame]
Yukai Tu05126792016-10-11 15:03:30 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2017, Regents of the University of California.
4 *
5 * This file is part of ChronoShare, a decentralized file sharing application over NDN.
6 *
7 * ChronoShare is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License along with
16 * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ChronoShare authors and contributors.
19 */
20
21#ifndef CHRONOSHARE_SRC_IO_SERVICE_MANAGER_HPP
22#define CHRONOSHARE_SRC_IO_SERVICE_MANAGER_HPP
23
24#include <ndn-cxx/face.hpp>
25#include <boost/asio/io_service.hpp>
26
27#define RECONNECTION_TIME 30000
28
29namespace ndn {
30namespace chronoshare {
31
32/// The class prevent face loss connection to NFD.
33class IoServiceManager : private boost::noncopyable
34{
35public:
36 /// Construct the server to listen on the specified TCP address and port, and
37 /// serve up files from the given directory.
38
39 IoServiceManager(boost::asio::io_service& io);
40
41 ~IoServiceManager();
42
43 /// Run the service's io_service loop.
44 void
45 run();
46
47 /// Handle a request to stop the service.
48 void
49 handle_stop();
50
51private:
52 /// the IO service used by NFD connection.
53 boost::asio::io_service& m_ioService;
54 std::unique_ptr<boost::asio::io_service::work> m_ioServiceWork;
55 bool m_connect;
56};
57
58} // namespace chronoshare
59} // namespace ndn
60
61#endif // CHRONOSHARE_SRC_IO_SERVICE_MANAGER_HPP