0

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?

4

1 回答 1

2

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

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

您可以使用orderBy, startAt,endAt andlimitTo...` 参数控制从该节点下返回的数据。例如

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

没有办法让单个 REST 请求从不同的节点/节点集返回数据。因此,除非您找到一种方法来收集要在单个节点下返回的所有数据,并且可以通过一组查询参数(orderBy等)返回,否则您将不得不执行多个 REST 请求来获取数据。

请注意,Firebase 内部提供的 SDK 使用 web-socket 协议,因此不受此限制的影响。如果您的服务器端语言(例如 node.js、Java)有可用的 SDK,您可以使用该语言解决它。

于 2015-05-26T14:19:29.270 回答