2014-12-02 18:34:02 +03:00
|
|
|
#ifndef BOB_H__
|
|
|
|
#define BOB_H__
|
|
|
|
|
2014-12-02 19:42:35 +03:00
|
|
|
#include <thread>
|
|
|
|
#include <memory>
|
|
|
|
#include <list>
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
#include "Streaming.h"
|
|
|
|
|
2014-12-02 18:34:02 +03:00
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace client
|
|
|
|
{
|
2014-12-02 19:42:35 +03:00
|
|
|
class BOBDataStream: public std::enable_shared_from_this<BOBDataStream>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
BOBDataStream (std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
|
|
|
std::shared_ptr<i2p::stream::Stream> stream);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::shared_ptr<boost::asio::ip::tcp::socket> m_Socket;
|
|
|
|
std::shared_ptr<i2p::stream::Stream> m_Stream;
|
|
|
|
};
|
2014-12-02 18:34:02 +03:00
|
|
|
|
|
|
|
class BOBCommandChannel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
BOBCommandChannel (int port);
|
|
|
|
~BOBCommandChannel ();
|
2014-12-02 19:42:35 +03:00
|
|
|
|
|
|
|
void Start ();
|
|
|
|
void Stop ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void Run ();
|
|
|
|
void Accept ();
|
|
|
|
void HandleAccept(const boost::system::error_code& ecode, std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
bool m_IsRunning;
|
|
|
|
std::thread * m_Thread;
|
|
|
|
boost::asio::io_service m_Service;
|
|
|
|
boost::asio::ip::tcp::acceptor m_Acceptor;
|
|
|
|
std::list<std::shared_ptr<BOBDataStream> > m_DataStreams;
|
2014-12-02 18:34:02 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|