X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=bigscreen%2Fccbs_bigscreen.cpp;h=71bd966cc1aad8e61c331feaa313605db5713634;hp=2dbb34a81fe21ac37550cbac08caaf1332b6bc92;hb=1640d1e1125f43a22770796b24895d18d945892f;hpb=c2208d9a688b56565cd84db6152181ebd26781a0;ds=inline diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index 2dbb34a..71bd966 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -3,12 +3,34 @@ #include #include "glwindow.h" +/* + * A trigger that exits whenever it's trigged (used when we change big things + * such as starting a new tournament, and it's not really worth doing a clean + * change). + */ +class ExitTrigger : pqxx::trigger { +public: + ExitTrigger(pqxx::connection_base &conn, const PGSTD::string &name) + : pqxx::trigger(conn, name) {} + virtual ~ExitTrigger() throw () {} + + virtual void operator() (int pid) + { + std::fprintf(stderr, "Received an exit trigger from pid %u\n", pid); + exit(0); + } +}; + int main(int argc, char **argv) { GLWindow glw("CCBS bigscreen", 800, 600, 32, false, 16, -1); try { pqxx::connection conn("dbname=ccbs host=sql.samfundet.no user=ccbs password=GeT|>>B_"); - pqxx::transaction<> t(conn, "trx"); + ExitTrigger et(conn, "bs_tournament_changed"); + + sleep(1); + + pqxx::work t(conn, "trx"); // fetch all songs pqxx::result res( t.exec("SELECT * FROM songs") ); @@ -16,6 +38,8 @@ int main(int argc, char **argv) std::fprintf(stderr, "%s\n", i["title"].c_str()); } t.commit(); + conn.get_notifs(); + sleep(1); } catch (const std::exception &e) { std::fprintf(stderr, "Exception: %s\n", e.what()); exit(1);