Android的 - 插座VS投票 [英] Android - Sockets vs Polling

查看:102
本文介绍了Android的 - 插座VS投票的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个Android应用程序我开发的部分有一个聊天室功能。我们具有可以处理传入消息和存储消息的服务器。它是更好地保持一个套接字连接手机和服务器之间的开放,使服务器可以发送任何新信息到手机上,或者是更好地为手机轮询服务器以获得新的聊天消息?

As part of an Android app I'm developing there is a chat room feature. We have a server which can process the incoming messages and store the messages. Is it better to keep a socket connection open between the phone and the server so the server can send any new messages to the phone, or is it better for the phone to poll the server for new chat messages?

推荐答案

这是坏的解决方案与轮询的应用程序,已经随机发送的数据。我想说的是,当你有什么事情正在发生分立就像每5分钟或类似的东西轮询的数据是非常有用的。这是不是与聊天的情况下,一些用户可以发布的东西的人在一个小时内,有些可以发布30次在2分钟内

It is bad solution with poll for app that have randomly posting data. What I want to say is that polling data is useful when you have something that is happening discrete like every 5 minutes or something like that. this is not the case with chat, some user can post something ones in a hour , some can post 30 times in 2 minutes

因此​​,保持你的插座打开

so keep your sockets open

这篇关于Android的 - 插座VS投票的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆