You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
931 B
39 lines
931 B
#ifndef _TR_WS_HPP_ |
|
#define _TR_WS_HPP_ |
|
|
|
#include <boost/system/error_code.hpp> |
|
#include <iostream> |
|
|
|
namespace tr { |
|
namespace ws { |
|
|
|
namespace status { |
|
const int normal = 1000; |
|
const int unexpected = 1011; |
|
} |
|
|
|
template <class Session, class Connection> |
|
void on_error(Session &session, Connection con, const boost::system::error_code &ec) { |
|
std::cerr << ec.message() << std::endl; |
|
} |
|
|
|
template <class Session, class Connection> |
|
void on_close(Session &session, Connection con, int status, const std::string &reason) { |
|
} |
|
|
|
template <class Server, class Session, class Connection> |
|
void on_open(Server &server, Session &session, Connection con) { |
|
if (session.is_valid()) { |
|
session.post_torrent_updates(); |
|
} else { |
|
server.send_close(con, status::unexpected, "Session not valid"); |
|
} |
|
} |
|
|
|
template <class Session, class Connection, class Message> |
|
void on_message(Session &session, Connection con, Message message) { |
|
} |
|
} |
|
} |
|
|
|
#endif |