简体   繁体   English

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

[英]Event-driven console user interface

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? 您能否就如何建模/实现此类用户界面或共享教程链接给我一些建议?

For prompt related tasks I suggest jline , it provides history, autocompletion etc... 对于快速相关的任务我建议jline ,它提供历史,自动完成等...

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 ) 我建议Netty实现网络协议,但也许你可以使用一些架子RPC( ProtobuffThriftAvro

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? 使客户端变得轻量级可能是个好主意,但也许一些性能/带宽考虑需要更智能的客户端?

也许这个图书馆 - http://www.pitman.co.za/projects/charva/index.html对您来说很有趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM