Skip to content

Catching a signal asynchronously #161

Answered by emilcarr
emilcarr asked this question in Q&A
Discussion options

You must be logged in to vote

To answer my own question...

As I hinted at in my question, the solution is to subscribe to the signal and enter the event loop in a new thread:

    std::thread signal_thread ([&connection, bus_name, stream_path](){
        stream_proxy = sdbus::createProxy(*connection, bus_name, stream_path);
        // subscribe for PipeWireStreamAdded signal
        stream_proxy->uponSignal("PipeWireStreamAdded")
            .onInterface("org.gnome.Mutter.ScreenCast.Stream")
            .call([&session](uint32_t& node_id){ 
                    printf("SIGNAL. RECEIVED.%i\n", node_id);
                    connection->leaveEventLoop(); // we only needed this one signal. we can leave now.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@sangelovic
Comment options

@emilcarr
Comment options

@emilcarr
Comment options

@sangelovic
Comment options

Answer selected by emilcarr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants