单个请求到多个异步响应
所以,问题来了。 iPhone 很棒,但对于有服务器端要求的应用程序来说,带宽和延迟是严重的问题。我解决这个问题的最初计划是对数据位发出多个请求(双关语无意),并以此来处理大量传入//传出数据的问题。由于很多原因,这是一个坏主意,对我来说最明显的是我可怜的数据库(MySQL)无法很好地处理这个问题。据我了解,最好一次请求大块,特别是如果我无论如何都要请求全部。
问题是现在我又在等待大量数据通过。我想知道是否有一种方法可以基本上向服务器发送一堆 ID 以从数据库获取,然后单个请求发送很多小响应,每个响应都包含有关单个数据库条目的所有信息。顺序无关紧要,理想情况下,我能够向服务器发送另一个请求,告诉它停止向我发送东西,因为我有我需要的东西。
我意识到这可能不是一件简单的事情,所以如果你们(很棒的)能够为我指明正确的方向,那也将是令人难以置信的。
当前系统是iPhone(Cocoa//Objective-C)-> PHP-> MySQL
提前非常感谢。
So, here's the problem. iPhones are awesome, but bandwidth and latency are serious issues with apps that have serverside requirements. My initial plan to solve this was to make multiple requests for bits of data (pun unintended) and have that be how the issue of lots of incoming//outgoing data was handled. This is a bad idea for a lot of reasons, most obvious to me is that my poor database (MySQL) can't handle this very well. From what I understand it's better to request large chunks all at once, especially if I'm going to ask for all of it anyways.
The problem is now I'm waiting again for a large amount of data to get through. I was wondering if there's a way to basically send the server a bunch of IDs to get from the database, and then that SINGLE request then sends a lot of little responses, each one containing all the information about a single db entry. Order is irrelevant, and ideally I'd be able to send another request to the server telling it to stop sending me things because I have what I need.
I realize this is probably NOT a simple thing to do so if you (awesome) guys could point me in the right direction that would also be incredible.
Current system is iPhone (Cocoa//Objective-C) -> PHP -> MySQL
Thanks a ton in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK,单个请求无法获得多个响应。从您的要求来看,您似乎需要分两部分进行。
第 1 部分:使用 ID 发送单个呼叫。
您的服务器会响应一条消息,其中包含调用唯一的“较小”答案所需的 URL 或信息。
第 2 部分:根据该响应列表,触发在各自线程上运行的多个请求。
我认为这类似于网页的工作方式。您可以在 Web 浏览器中调用 HTML URL。 HTML 告诉浏览器它需要获取附加部分(图像、CSS、JS 等)来构建完整页面的所有位置/URL。
希望这有帮助。
AFAIK, a single request cannot get multiple responses. From what you are asking, it seems that you need to do this in two parts.
Part 1: Send a single call with the IDs.
Your server responds with a single message that contains the URLs or the information needed to call the unique "smaller" answers.
Part 2: Working from that list of responses, fire off multiple requests that run on their own threads.
I am thinking of this similar to how a web page works. You call the HTML URL in a web browser. The HTML tells the browser all the places/URLS it needs to get additional pieces (images, css, js, etc) to build the full page.
Hope this helps.