从移动机架服务器接收更新 [英] Receive update from server with mobile framework

查看:110
本文介绍了从移动机架服务器接收更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个移动应用程序,我发现离子框架,显得更酷。

I'm trying to make a mobile application and I found ionic framework which seems cool.

看来,剩下的就是做事情的一种常见方式,我不明白一件事这个协议。服务器如何通知他有数据要发送。如果我们有一个文本应用程序,如何在服务器通知应用程序(不包括推送通知,或者他们是强制性的?)另外一个客户端发送您的消息?

It seems that REST is a common way to do things and I don't understand one thing with this protocol. How does the server notify that he has data to send. If we have a text application, how does the server notify the application (without push notification, or maybe they're mandatory ?) that another client sent you a message ?

好像REST只对来自客户机的请求不错。这是否意味着我必须发送请求更新每隔X毫秒有一个敏感的应用?我一定要使用WebSockets这样的目的是什么?我也看到彗星,它是利用休息的好办法?

It seems like REST is only good for the requests coming from the client. Does it means that I have to send request for update every X milliseconds to have a responsive application ? Do I have to use websockets for such purpose ? I also saw Comet, is it a good way to use rest ?

推荐答案

REST架构并没有真正解决发布/订阅(发布/订阅)范例。它更粗的比。

The REST architecture doesn't really address "Publication/Subscription" (pub/sub) paradigms. It's much more coarse than that.

与发布/订阅的主要问题是技术性的,尤其是在今天。在一个完全连接互联网的一切是在网上已知位置的时候,那么基本REST架构只是工作。简单地说,客户端和服务器交换来回的角色(即服务器就当它需要发送一个通知的客户端)。

The major issues with pub/sub are technical, especially today. In a fully connected internet where everything is online at known locations all the time, then the basic REST architecture just works. Simply, the roles of Client and Server swap back and forth (i.e. the Server becomes a Client when it needs to send an notification).

但是,这不是真实的世界。

But that's not the real world.

现实的世界,而我们有很多连接的设备,我们没有很多已知位置的。您的手机周围的一切,谁知道IP地址是什么它在任一时刻的一次举动。 DNS没有帮助,因为你的手机很有可能不会在任何特定的已知名称注册。再有就是在那里,绝大多数客户都锁定了,在那里他们可以发送信息基础设施的问题,但不能接收他们,即使我们都知道谁,他们在哪里。

The real world is while we have a lot of connected devices, we do not have a lot of known locations. Your phone moves around all the time, and who knows what IP address it's at at any one time. DNS doesn't help because your phone is likely not registered under any particular known name. Then there's infrastructure issues where the vast majority of clients are locked away to where they can send messages, but can not receive them, even if we did know who and where they were.

所以,REST并未探讨这方面的,只是因为它违反了一般的几个关键属性。

So, REST doesn't explore that area simply because it typically violates a few key attributes.

其一是,URL消失。因为我们不知道你在哪里,或谁,我们不能名字得到你。因此,单向乡亲解决它是通过长寿命的连接。您的客户端挂接到服务器,并保留其连接,从而使服务器可以顶嘴。但是,这是一个隐状态连接。 REST对无国籍驱动器,并且是在架构层面有效连接。

One is that the URL goes away. Since we don't know where or who you are, we can't get to you by name. So, one way folks get around it is through long lived connections. Your client hooks up to the server and retains its connection so that the server can talk back. But this is an implicitly stateful connection. REST drives towards statelessness, and is effectively connectionless at the architecture level.

所以,在这种环境中,REST不是一个合适的体系结构,由于力学不能支持的一些基本precepts的

So, in that environment, REST is not an appropriate architecture, since the mechanics can not support some of the fundamental precepts.

这篇关于从移动机架服务器接收更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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