>The programs in the "test" directory contain working examples of all
>libpqxx functions.  You can find the trigger class in test/test004.cxx
>(it's also used in tests 23, 78, 79, and 87).
Thank for the tests, I forgot about them (they are not included in rpm 
packages as well as pqxx documentation).

>I think the problem with your test is that you don't call any libpqxx
>functions while you wait for notification, so there is no way for the
>library to deliver the notifications to your trigger!  
Ok. It works, thanks a lot. I really need to make some event loop to react on 
NOTIFY command. I do not decide yet to use Qt for this purpose or not. I see 
that connection::socket()  just calls PQsocket(conn) from libpq and there 
will no problem to make some combination of Qt & pqxx to emit Qt signals.  
But I see that trigger class will not help here at least for now. 

How about to implement above testlibpq2.c example functionality (or 
await_notification() functionality) in pqxx::trigger using select() <stdio.h>  
to read from socket, or to receive "event" from socket without calling any 
libpqxx function. I think it will be very simple, nice-looking and logically 
properly to make such constructions:
----------------------- test_libpqxx.h: ------------------------------------
#ifndef TEST_LIBPQXX_H
#define TEST_LIBPQXX_H

#include <iostream>
#include <pqxx/pqxx>    // PostgreSQL C++ interface library
using namespace PGSTD;
using namespace pqxx;
//---------------------------------------------------------------------
class DTrendTrigger : public trigger, public QObject
{
public:
    DTrendTrigger(connection_base &C, const string &N)
        : trigger(C, N) {};

    virtual void operator()(int pid) {
        emit someSignal();
    };
};
//---------------------------------------------------------------------
#endif // TEST_LIBPQXX_H

I saw similar ideas was discussed here year ago. However, I think 
await_notification() functionality will be enough for me for the first time.

>Call the connection's get_notifs() periodically, or even simpler: instead of
>writing your own pause function, just use the connection's
>await_notification() functions.
Its interesting: there is nothing about this functions in documentation, only 
in "pqxx/connection_base.hxx" listing and without comments. Need to look in 
source. Doxygen problem, bug?

Thanks again for your time.

-- 
Best regards,
Aleksey.

P.S. Sorry for previous post.
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general

Reply via email to