#include "config.h" #include "music.h" #include "decoder.h" #include "encoder.h" #include "httpd.h" #include "telnetd.h" #include "http_static.h" #include "http_json.h" #include #include #include void foo_handler(HTTP::Connection::p connection) { std::cout << "Handling!" << std::endl; MusicListing::p ml = music::get(connection->path); if(ml) { ml->render(connection); } else { connection->send_error(404); } } int main(int argc, char **argv) { try { config::init(); music::init(config::vm["audist.music_root"].as()); Decoder::init(); Encoder::init(); boost::asio::io_service io_service; HTTP::Server httpd(io_service, tcp::endpoint(tcp::v6(), config::vm["audist.httpd_port"].as())); httpd.add_handler("files", &foo_handler); HTTP::Static static_files("static"); httpd.add_handler("static", static_files); httpd.add_handler("", static_files); HTTP::JSON http_json; httpd.add_handler("list", http_json); telnet::Server telnetd(io_service, tcp::endpoint(tcp::v6(), config::vm["audist.telnetd_port"].as())); std::size_t num_threads = config::vm["audist.threads"].as(); std::vector > threads; for(std::size_t i = 0; i < num_threads; i++) { boost::shared_ptr thread(new boost::thread(boost::bind(&boost::asio::io_service::run, &io_service))); threads.push_back(thread); } for(std::size_t i = 0; i < num_threads; i++) { threads[i]->join(); } } catch(std::exception& e) { std::cerr << e.what() << std::endl; } return 0; }