Firebase可以处理数据,并将结果推送到移动设备,而不是仅仅推送原始数据? [英] Can firebase process the data and push the result to mobile devices instead of just push the original?

查看:101
本文介绍了Firebase可以处理数据,并将结果推送到移动设备,而不是仅仅推送原始数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firebase可以同步不同移动设备之间的数据以进行实时应用。我可以使用firebase对这些数据执行任何服务器端操作,只将这些操作的结果推送到感兴趣的设备而不是原始数据?

像移动设备上的号码从10变为100时,服务器只是推一个标志表示较大,而不是将新号码100推到其他设备。

解决方案

Firebase本身并不能为您提供在服务器上运行数据操作代码的方法。 >

在最简单的情况下,您可以简单地让客户端计算这些派生值,使用事务客户的影响(如您的示例所示)。
$ b 您也可以设置自己的服务器来监控您的Firebase数据(可能通过您为客户使用的相同API)计算这些派生值并将其写回Firebase。实际的移动设备将只是监视派生的值。然后,该服务器应该在提升/受信任的帐户下运行,或者使用知名的名称,或者使用您可以在Firebase仪表板/伪造中找到的秘密。

你甚至可以像客户一样做。所以,只要有一个网页,您可以在您控制的机器上运行,而其他人则无法访问。但是你可能最好为此设置一个单独的(例如node.js)服务器。



最重要的是,你不需要真正的服务器在托管/数据中心来完成您的需求。 Firebase是防火墙友好型的,与许多其他服务不同,您不需要提供可公开访问的回发网址,以便他们打电话给您。因此,您可以在家中运行应用程序的服务器部分(取决于您的机器的可靠性,互联网连接以及您的应用程序派生数据的最新需求)。

Firebase can synchronize data among different mobile devices for real time application. Can I use firebase to perform any server side operations on those data and only push the result of those operations to interested devices, instead of raw data?

Like when a number on a mobile device is changed from 10 to 100, the server simply pushes a flag indicates larger, instead of pushing the new number, 100, to other devices.

解决方案

Firebase by itself does not provide you with a way to run your data manipulation code on their servers.

In the simplest case you can simply let the clients calculate those derived values, using a transaction in case there is a cross-client impact (as your example suggests).

You can also set up your own server that monitors your Firebase data (possibly through the same API you use for your clients), calculates those derived values and writes them back into Firebase. The actual mobile devices would then just be monitoring the derived values. This server should then be running under an elevated/trusted account, either a well-known name or by using the secret that you can find in your Firebase dashboard/forge.

You could even do the same as a client. So just have a web page that you run on a machine that you control and others can't access. But you're probably better off setting up a separate (e.g. node.js) server for this.

The most important thing to realize is that you don't need a real server at a hosting/data center to accomplish your needs. Firebase is firewall-friendly, unlike with many other services you don't need to provide a publicly reachable postback URL that they will call you on. So you can just run the "server" part of your application at home (depending on the reliability of your machine, internet connection and the up-to-date requirements of the derived data for your application).

这篇关于Firebase可以处理数据,并将结果推送到移动设备,而不是仅仅推送原始数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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