简体   繁体   English

与 node.js 实时聊天

[英]Real-time chat with node.js

I am wonder which way would be better to write chat application.我想知道哪种方式会更好地编写聊天应用程序。

First idea to send message with HTTP request, save in the database, and resend message to recipient using sockets.第一个想法是使用 HTTP 请求发送消息,保存在数据库中,然后使用套接字将消息重新发送给收件人。

Second idea is to do it using only sockets.第二个想法是只使用套接字来做到这一点。

I wonder, because I have access and refresh token authentication system with HTTP request, and I think that this way would be safer..我想知道,因为我可以使用 HTTP 请求访问和刷新令牌身份验证系统,我认为这种方式会更安全..

Either way works.无论哪种方式都有效。 Most people use sockets, but you can have a database to save logs and the such.大多数人使用套接字,但您可以拥有一个数据库来保存日志等。 Token authentication is usually done before entering the chat application, but it's up to whatever design you want.令牌验证通常在进入聊天应用程序之前完成,但这取决于您想要的任何设计。 If you have no need for logs, just use normal sockets.如果您不需要日志,只需使用普通套接字即可。

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

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