问题描述
我使用Java开发了一个聊天应用程序,但是现在的挑战是在Web应用程序中构建一个聊天应用程序.我不知道如何继续.我们可以像在Java中那样使用套接字吗?
I developed a chat application using java.But now my challenge is build a chat app in web application.I dont how to proceed.Can we use sockets as done in java.
请给我一个建议,以解决这个问题.
Please give me a suggestion to get through this.
预先感谢.
推荐答案
我建议您使用 websockets ,因为它们在服务器和html客户端之间实时交换(推式而不是拉式)数据非常有效.它们是双向的,并且大致等同于您习惯的套接字(因此得名).在客户端,它们使用与ajax客户端相同的基于回调的逻辑,但这并不意味着它们并不快.
I recommend you to use websockets as they're really efficient to exchange in real time (push instead of pull) data between a server and html clients. They're bidirectionnal and roughly equivalent to the sockets you're used to (hence their name). Client-side, they use the same callback based logic than ajax clients but that doesn't mean they're not fast.
这是一个教程: http://java.dzone.com/articles/creating- websocket聊天
搜索"java chat websocket"会给您其他结果.
Googling "java chat websocket" would give you other results.
这篇关于如何使用jsp和servlet进行聊天应用程序的制作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!