如何向我的桌面应用程序通知远程服务器上的状态更改?

发布于 2024-09-28 14:51:02 字数 264 浏览 2 评论 0原文

我正在创建一个桌面应用程序,在本地执行某些操作之前需要获得远程服务器的授权。

当服务器批准授权请求时,通知我的桌面应用程序的最佳方式是什么?授权平均需要 20 秒,最短需要 5 秒,超时时间为 120 秒。

我考虑过每隔 3 秒左右轮询一次服务器,但是当我更广泛地部署应用程序时,这将很难扩展,而且看起来不优雅。

我可以完全控制服务器和客户端 API 的设计。服务器在 Ubuntu 10.10、Python 2.6 上使用 web.py

I'm creating a desktop application that requires authorization from a remote server before performing certain actions locally.

What's the best way to have my desktop application notified when the server approves the request for authorization? Authorization takes 20 seconds average on, 5 seconds minimum, with a 120 second timeout.

I considered polling the server ever 3 seconds or so, but this would be hard to scale when I deploy the application more widely, and seems inelegant.

I have full control over the design of the server and client API. The server is using web.py on Ubuntu 10.10, Python 2.6.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寄与心 2024-10-05 14:51:02

远程端在进行身份验证时是否会阻塞?如果是这样,您可以使用简单的 select 来阻止直到它返回。

我能想到的另一种方法是将回调 URL 传递给身份验证服务器,要求其在完成后调用它,以便您的客户端应用程序可以继续。类似网络钩子的东西。

Does the remote end block while it does the authentication? If so, you can use a simple select to block till it returns.

Another way I can think of is to pass a callback URL to the authentication server asking it to call it when it's done so that your client app can proceed. Something like a webhook.

隐诗 2024-10-05 14:51:02

你需要做一些异步的事情。我一直是 twisted 的忠实粉丝,它是一个在 python 中进行异步网络的框架。它支持许多常见协议,并具有自行推出的管道。如果扭曲似乎有点过分,您可以在此处比较其他异步框架

You need to do something asynchronous. I've always been a big fan of twisted, which is a framework for doing async networking in python. It supports a lot of common protocols and has the plumbing to roll your own. If twisted seems a bit overkill, you can compare other async frameworks here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文