Migrate from deprecated notification_receiver to connection::listen()
libpqxx 7.10.1 deprecates the notification_receiver class.
This commit is contained in:
@@ -27,19 +27,20 @@ struct Connection : pqxx::connection
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class receiver : public pqxx::notification_receiver
|
class receiver
|
||||||
{
|
{
|
||||||
std::optional<std::string> status;
|
std::optional<std::string> status;
|
||||||
|
pqxx::connection & conn;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
receiver(pqxx::connection_base & c, const std::string & channel)
|
receiver(pqxx::connection_base & c, const std::string & channel)
|
||||||
: pqxx::notification_receiver(c, channel) { }
|
: conn(static_cast<pqxx::connection &>(c))
|
||||||
|
|
||||||
void operator() (const std::string & payload, int pid) override
|
|
||||||
{
|
{
|
||||||
status = payload;
|
conn.listen(channel, [this](pqxx::notification n) {
|
||||||
};
|
status = std::string(n.payload);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<std::string> get() {
|
std::optional<std::string> get() {
|
||||||
auto s = status;
|
auto s = status;
|
||||||
|
Reference in New Issue
Block a user