|
|
|
@ -1,31 +1,32 @@ |
|
|
|
#ifndef _TR_TORRENT_HPP_ |
|
|
|
#ifndef _TR_WS_HPP_ |
|
|
|
#define _TR_TORRENT_HPP_ |
|
|
|
#define _TR_WS_HPP_ |
|
|
|
|
|
|
|
|
|
|
|
#include <boost/system/error_code.hpp> |
|
|
|
#include <boost/system/error_code.hpp> |
|
|
|
#include <iostream> |
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
|
|
|
|
namespace tr { |
|
|
|
namespace tr { |
|
|
|
namespace ws { |
|
|
|
namespace ws { |
|
|
|
enum status { |
|
|
|
namespace status { |
|
|
|
normal = 1000, |
|
|
|
const int normal = 1000; |
|
|
|
|
|
|
|
const int unexpected = 1011; |
|
|
|
}; |
|
|
|
}; |
|
|
|
template <class Session, class Connection> |
|
|
|
template <class Session, class Connection> |
|
|
|
void on_error(Session session, Connection con, const boost::system::error_code &ec) { |
|
|
|
void on_error(Session &session, Connection con, const boost::system::error_code &ec) { |
|
|
|
std::cerr << ec.message() << std::endl; |
|
|
|
std::cerr << ec.message() << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
template <class Session, class Connection> |
|
|
|
template <class Session, class Connection> |
|
|
|
void on_close(Session session, Connection con, status sta, const std::string &reason) { |
|
|
|
void on_close(Session &session, Connection con, int status, const std::string &reason) { |
|
|
|
} |
|
|
|
} |
|
|
|
template <class Server, class Session, class Connection> |
|
|
|
template <class Server, class Session, class Connection> |
|
|
|
void on_open(Server &server, Session &session, Connection con) { |
|
|
|
void on_open(Server &server, Session &session, Connection con) { |
|
|
|
if (session.is_valid()) { |
|
|
|
if (session.is_valid()) { |
|
|
|
session.post_torrent_updates(); |
|
|
|
session.post_torrent_updates(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
server.send_close(con, status::normal, "Session not valid"); |
|
|
|
server.send_close(con, status::unexpected, "Session not valid"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
template <class Session, class Connection, class Message> |
|
|
|
template <class Session, class Connection, class Message> |
|
|
|
void on_message(Session session, Connection con, Message message) { |
|
|
|
void on_message(Session &session, Connection con, Message message) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|