从 Linux 服务器与 C# 桌面应用程序通信的选项?
桌面应用程序正在开发一个演示版本,该版本应该运行几分钟,之后将要求用户重新启动应用程序以再次运行(用户必须输入登录名和密码才能访问它) ,因为我在这个领域了解不多,所以我可以想到在用户不绕过它的情况下执行此操作的方式是在两者或类似的东西之间进行实时通信。
X 分钟后,服务器发送 向客户端发送消息以关闭/禁用 客户端要求用户 重启一下,也限制了每日 同一用户在演示中的使用情况。
由于我在这种类型或通信方面非常缺乏经验,因此我想向你们咨询我这里有哪些选项?
桌面应用程序是用 C# 开发的,主要在 Windows 操作系统上运行,而我们仅在服务器上运行有Linux可用,以及什么样的服务,如果可以在php或perl中创建一个足够可靠的webapi或会话来使用它,那就太好了,但如果不可能,我们愿意听取其他选择。
PS:如果我没有提供足够的信息或在这里遗漏了任何重要的内容,请给我留言,我会尽快更新。
The desktop application is being developed with a demo version that is supposed to run for a few minutes and after that would request the user to restart the application to run again (the user has to input their login and password to access it), since I dont know much in this field the way I can think of doing this without the user bypassing it would be having a realtime communication between both or something of the sorts.
After X minutes the server sends a
message to the client to close/disable
the client requiring the user to
restart it, it also limits the daily
usage on the demo for the same user.
As I am very inexperienced in this type or communication I would like to consult you guys with what options I have here ?
The desktop application is developed in c# to run mainly on windows OS as for the server we only have linux available and as to what sort of service, if it is possible to make a webapi or session in php or perl to work with it that would be reliable enough would be nice but if that is not possible we are open to hear other options.
PS: If I have'nt given enough information or am missing anything important here please drop me a comment i will update as soon as possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会尝试使用基于相互证书的身份验证的 HTTPS 作为最安全的选择。桌面应用程序可以轮询服务器(=定期询问)并在无响应/无连接/否定响应的情况下退出。
但是,根据您正在开发的应用的类型和目标受众,您可以预期大量用户存在连接问题或完全没有连接。
因此,最终,您可以想出更简单的解决方案,例如在本地测量运行时间而不涉及任何服务器,并获得几乎相同的效果。
I'd give a go to HTTPS with mutual certificate-based authentication as the safest option. The desktop app can poll the server (=ask periodically) and quit in case of no response / no connection / negative reponse.
However, based on the type of app you are developing and the target audience, you can expect an important amount of users to have connectivity problems or have no connectivity at all.
Because of this, at the end of the day, you can come up with a lot simpler solution, like measuring run-time locally without any server involved, and gain pretty much the same effect.
我认为您不需要使用服务器来执行此操作。
只需让桌面应用程序保存启动时的日期和时间即可。您可以定期在计时器上检查当前时间,看看演示版本是否已经过去了太多时间,并告诉用户必须退出。
许多用户不太可能尝试解决这个问题。他们更有可能放弃您的试用软件,转而选择对他们有利的软件!
I don't think you need to involve a server to do this.
Just have the desktop application save the date and time when it started. Periodically on a timer you can check the current time, and see if too much time has elapsed for the demo version, and tell the user they have to quit.
It is very unlikely many users will try to get around this. They are more likely to dump your trial software in favour of something that treats them decently!
检查 DateTime.Now 可以像 Ben 所说的那样工作,但你最好使用 System.Timers.Timer。将间隔设置为您所需的身份验证调用之间的间隔(以毫秒为单位)。将处理程序附加到请求身份验证信息的已过去事件。 System.Timers.Timer 在单独的线程中工作,因此您可以在此处利用一些并行性。更改系统时间不应该对 System.Timers.Timer 产生任何影响,但我对此并不乐观。
Checking DateTime.Now could work as Ben stated, but you'd be better off with System.Timers.Timer. Set interval to be your desired interval between auth calls in milliseconds. Attach a handler to the elapsed event that asks for auth info. System.Timers.Timer works in a separate thread so you can take advantage of some parallelism here. Changing the system time shouldn't have any effect on System.Timers.Timer but I am not positive on that point.