针对多个用户的Firebase REST流式传输 [英] Firebase REST streaming for multiple users

查看:166
本文介绍了针对多个用户的Firebase REST流式传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台需要从Firebase接收实时更新的服务器,对于多个用户,每个用户都可以将Oauth访问他的Firebase数据授予我的应用。

我的服务器使用 Firebase REST Streaming ,基于Server Sent Events。



我需要知道是否有办法在单个流上复用与多个用户相关的Firebase数据。

我希望能够设置与多个用户相关的Oauth令牌,并随后接收实时更新有关的多个用户在同一个流。

否则,我似乎需要维护一个单独的流每Oauth令牌,这似乎是非 - 我认为Twitter有一个网站流

/ a>功能就像我在他们的API中寻找的,通过一个信封实现的,这个信封指明了用户的消息目标。

Firebase是否支持类似的功能? / p>

解决方案

单个Firebase REST调用将仅监视单个节点。例如

  curl'https://samplechat.firebaseio-demo.com/users/jack/name.json'

您可以使用 orderBy startAt, endAt limitTo ...`参数。例如

  curl'https://samplechat.firebaseio-demo.com/users/.json?orderBy=\"name\"& ; startAt =Jack'

没有办法让一个REST请求返回不同的数据节点/节点集。所以,除非你找到一种方法来收集你想在单个节点下返回的所有数据,它可以由一组查询参数( orderBy 等)返回,你必须执行多个REST请求才能获取您的数据。



请注意,Firebase内部提供的SDK使用Web套接字协议,因此不受此限制的影响。如果一个SDK可用于你的服务器端语言(例如node.js,Java),你可以使用它来解决它。


I have a server that needs to receive real time updates from Firebase, for multiple users, where each user grants Oauth access to his Firebase data to my app.

My server is implemented using Firebase REST Streaming, based on Server Sent Events.

I need to know if there is a way to multiplex Firebase data pertaining to multiple users on a single stream.

I would like to be able to set up the stream with Oauth tokens pertaining to multiple users, and to subsequently receive real time updates pertaining to the multiple users on the same stream.

Otherwise, it seems that I need to maintain a separate stream per Oauth token, which seems to be non-scalable.

I think Twitter have a Site Streams feature like what I am looking for in their API, implemented via an envelope that indicates the user the message is targetted to.

Does Firebase support anything similar?

解决方案

A single Firebase REST call will only monitor a single node. E.g.

curl 'https://samplechat.firebaseio-demo.com/users/jack/name.json'

You can control what data is returned from under that node with the orderBy, startAt,endAtandlimitTo...` parameters. E.g.

curl 'https://samplechat.firebaseio-demo.com/users/.json?orderBy="name"&startAt="Jack"'

There is no way to have a single REST request return data from different nodes/nodesets. So unless you find a way to gather all data you want to return under single node, where it can be returned by a single set of query parameters (orderBy, etc), you will have to execute multiple REST requests to get your data.

Note that the SDKs that Firebase provides internally use a web-socket protocol, so are not impacted by this limitation. If an SDK is available for your server-side language (e.g. node.js, Java), you could solve it by using that one.

这篇关于针对多个用户的Firebase REST流式传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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