Beispiel #1
0
void tws::mongoose::server::start()
{
    pimpl_->stop_ = false;

    struct mg_mgr server_;
    struct mg_connection* conn_;

    tws_mongoose_http_config conf = tws_mongoose_read_config_file();

    mg_mgr_init(&server_, NULL);

    conn_ = mg_bind(&server_,
                    boost::lexical_cast<std::string>(conf.listening_port).c_str(),
                    tws_mongoose_event_handler);

    mg_set_protocol_http_websocket(conn_);

    if(conf.max_threads > 1)
        mg_enable_multithreading(conn_);
    \

    while(pimpl_->stop_ == false)
    {
        mg_mgr_poll(&server_, 1000);
    }
    mg_mgr_free(&server_);
}
Beispiel #2
0
int main(int argc, char **argv) {
  signal(SIGINT, signal_handler);

  if (sqlite3_open("tpod.db", &db) != SQLITE_OK) {
    printf("failed to open database: %s\n", sqlite3_errmsg(db));
    cleanup();
    return 1;
  }

  mpg123_init();

  ao_initialize();

  if (strcmp("-s", argv[1]) == 0) {
    struct mg_mgr mgr;
    struct mg_connection *con;

    mg_mgr_init(&mgr, NULL);
    con = mg_bind(&mgr, "8080", ev_handler);
    mg_set_protocol_http_websocket(con);
    mg_enable_multithreading(con);
    s_http_server_opts.document_root = "./static";

    while (srv) {
      mg_mgr_poll(&mgr, 1000);
    }

    mg_mgr_free(&mgr);
    cleanup();

    exit(130);
  } else {
    mode = 1;
    play_stream(argv[1]);
    cleanup();
  }

  return 0;
}