事件驱动的控制台用户界面

发布于 2024-12-09 08:09:02 字数 126 浏览 0 评论 0原文

我正在编写一个带有基于控制台的用户界面(在客户端)的服务器客户端应用程序。用户会看到提示并可以输入命令。另外,服务器会时不时地发出一条消息,客户端应处理并打印出相关信息。您能否给我一些关于如何建模/实现此类用户界面的建议或分享教程的链接?

I'm writing a server-client application with console based user interface (on the client side). The user is presented with a prompt and has the possibility to type in commands. Also, from time to time, the server will send out a message that the client should process and print out information about. Could you give me a piece of advice as to how go about modelling/implementing this type of user interface or share a link to a tutorial?

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

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

发布评论

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

评论(2

你穿错了嫁妆 2024-12-16 08:09:02

对于提示相关的任务,我建议 jline,它提供历史记录、自动完成等...

其他考虑因素可能包括:有多复杂是命令吗?起草一些语法。您是否需要一个合适的解析器来实现它们,或者正则表达式就足够了?即使您需要一个解析器,手写的解析器是否可以胜任这项工作?

客户端和服务器如何连接?它们之间有什么协议?每种方式可以设置的草案规范。我建议使用 Netty 来实现网络协议,但也许你可以使用一些现成的 RPC (< a href="https://code.google.com/apis/protocolbuffers/" rel="nofollow">Protobuff,ThriftAvro

哪部分工作在哪里完成?让客户端变得轻量级可能是个好主意,但也许某些性能/带宽考虑因素需要更智能的客户端?

For prompt related tasks I suggest jline, it provides history, autocompletion etc...

Other considerations might include: how complex are the commands? Draft some grammar. Do you need a proper parser to implement them, or regex would suffice? Even if you need a parser is some hand written one OK for the job?

How are client and a server connected? What protocol sits between them? Draft spec of what could be set each way. I would recommend Netty for implementing network protocols, but maybe you could go with some of the shelf RPC's (Protobuff, Thrift, Avro)

What part of work is done where? Making a client as lightweight is probably good idea, but maybe some performance/bandwidth considerations call for a bit smarter client?

始终不够 2024-12-16 08:09:02

也许这个库 - http://www.pitman.co.za/projects/charva /index.html 您可能会感兴趣。

Maybe this library - http://www.pitman.co.za/projects/charva/index.html could be interesting for you.

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