简体   繁体   English

Flutter:异步消息,如whatsapp

[英]Flutter: async message like whatsapp

我的应用程序中有一个聊天系统,我希望该应用程序每次都在api上监听,以查看是否没有类似whatsapp的新消息。但是我不知道如何继续

What you are looking for is probably WebSockets . 您正在寻找的可能是WebSockets WebSockets provide duplex communication which are used to communicate between a server and a client. WebSocket提供双工通信,用于在服务器和客户端之间进行通信。 Ideally, you want to implement a publish-subscribe mechanism where you can Publish from your server and subscribe on the client, which is your chat app. 理想情况下,您想要实现一种发布-订阅机制,您可以在其中从服务器进行发布并在客户端(即您的聊天应用程序)上进行订阅。 There are many open source, PAAS, IAAS solutions which can be used to achieve what you want to achieve. 有许多开源,PAAS,IAAS解决方案可用于实现您想要实现的目标。

For open source, I would recommend you check out socket.io . 对于开源,我建议您检出socket.io

Keep in mind that when running socket.io , you have to deal with scaling and hosting the server version yourself. 请记住,在运行socket.io时 ,您必须自己扩展和托管服务器版本。 To avoid this, a lot of people usually go with PAAS or IAAS services. 为了避免这种情况,很多人通常会使用PAAS或IAAS服务。

For PAAS services, I have used and would recommend ably . 对于PAAS服务,我已经使用并建议干练

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

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