From 5c5c824a38b02e166b5b012f17cf77dcb38d59d6 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 18 Feb 2005 17:55:57 +0000 Subject: [PATCH] Try to listen on a NOTIFY trigger. --- bigscreen/ccbs_bigscreen.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index 6afc0a0..bd8b37b 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -3,11 +3,32 @@ #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 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_"); + ExitTrigger et(conn, "bs_tournament_changed"); + + sleep(1); + pqxx::work t(conn, "trx"); // fetch all songs @@ -16,6 +37,8 @@ int main(int argc, char **argv) std::fprintf(stderr, "%s\n", i["title"].c_str()); } t.commit(); + + sleep(1); } catch (const std::exception &e) { std::fprintf(stderr, "Exception: %s\n", e.what()); exit(1); -- 2.39.2