سؤال

So right now I have rpyc client A that scrapes data and when it finds specific data it sends it to my rpyc server which is then stored. Lets say that I also have rpyc client B, C and D connected to my rpyc server as well. How can I make it so that the server can send that data directly to client C?

هل كانت مفيدة؟

المحلول

Since rpyc is symmetric, clients can pass callbacks for the server to call. The callbacks then get executed in the client process. That's probably the simplest and cleanest way to do what you want.

So your server needs to expose a new register_callback(client_callback) method, which stores the callbacks in a list. Then, whenever new data is received, you simply invoke all stored callbacks.

You'd also need to handle the case where a client which had registed a callback has already disconnected. It should be as simple as adding the correct try/except around the callback call (though I don't remember what's the actual exception type you'd need to catch).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top