]> git.sesse.net Git - ccbs/commitdiff
Try to listen on a NOTIFY trigger.
authorSteinar H. Gunderson <sesse@samfundet.no>
Fri, 18 Feb 2005 17:55:57 +0000 (17:55 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Fri, 18 Feb 2005 17:55:57 +0000 (17:55 +0000)
bigscreen/ccbs_bigscreen.cpp

index 6afc0a082b2ea90b2a8f916af02961a4312be582..bd8b37b05ea87e1cd21ea5c8aaeeb3dfd24812a0 100644 (file)
@@ -3,11 +3,32 @@
 #include <pqxx/pqxx>
 #include "glwindow.h"
 
 #include <pqxx/pqxx>
 #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_");
 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
                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();
                        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);
        } catch (const std::exception &e) {
                std::fprintf(stderr, "Exception: %s\n", e.what());
                exit(1);