对多个异步响应的单个请求 [英] Single request to multiple asynchronous responses

查看:124
本文介绍了对多个异步响应的单个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,这就是问题所在. iPhone很棒,但是带宽和延迟是具有服务器端要求的应用程序的严重问题.解决这个问题的最初计划是对数据位进行多次请求(双关语是无意的),并以此方式处理大量传入/传出数据的问题.由于很多原因,这是一个坏主意,对我来说最明显的是我的数据库(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.

问题在于,我现在又在等待大量数据通过.我想知道是否有一种方法可以基本上向服务器发送一堆从数据库中获取的ID,然后该SINGLE请求然后发送很多小响应,每个响应都包含有关单个db条目的所有信息.订单无关紧要,理想情况下,我可以向服务器发送另一个请求,告诉它停止发送东西,因为我有需要.

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.

当前系统为iPhone(Cocoa//Objective-C)-> PHP-> MySQL

Current system is iPhone (Cocoa//Objective-C) -> PHP -> MySQL

提前感谢一吨.

推荐答案

AFAIK,单个请求无法获得多个响应.从您的要求看来,您似乎需要分两部分进行此操作.

AFAIK, a single request cannot get multiple responses. From what you are asking, it seems that you need to do this in two parts.

第1部分::使用ID发送一个呼叫.

Part 1: Send a single call with the IDs.

您的服务器以一条消息进行响应,其中包含URL或调用唯一的较小"答案所需的信息.

Your server responds with a single message that contains the URLs or the information needed to call the unique "smaller" answers.

第2部分:从该响应列表开始,触发在其自己的线程上运行的多个请求.

Part 2: Working from that list of responses, fire off multiple requests that run on their own threads.

我认为这类似于网页的工作方式.您在网络浏览器中调用HTML URL. HTML会告诉浏览器获取其他部分(图像,css,js等)以构建整个页面所需的所有位置/URL.

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.

希望这会有所帮助.

这篇关于对多个异步响应的单个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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