gpt4 book ai didi

firebase - 我可以在 Firebase 中实现 channel 的概念吗?

转载 作者:行者123 更新时间:2023-12-04 19:11:07 27 4
gpt4 key购买 nike

Firebase 聊天应用程序似乎建议所有客户端都会收到发送到给定 FireBase url 的消息。

现在,确保用户只接收发送到特定 channel 的消息的一种方法是在客户端过滤消息,但这意味着所有消息都将传播到所有客户端,并且客户端将进行过滤。

有什么方法可以在 Firebase 服务器上建立 channel - 或者这是否意味着需要为单独的 channel 创建单独的 Firebase,这意味着如果想要特定于用户的推送消息,则可能需要创建一个 channel /firebase对于每个用户。

那么,建议的解决方案是什么?

最佳答案

Firebase Data Structure使这很容易,实际上!演示应用程序将聊天消息放在 Firebase 的根目录中(即 https://samplechat.firebaseio.com/ ),但您也可以轻松地在 Firebase 中使用不同的位置进行单独的聊天,例如/chat1、/chat2 等。或者更好的是,你可以有一个/chat/位置,下面有任意数量的聊天,每个都唯一命名(可能使用 push())。

然后用户可以通过直接引用它来接收消息并将其推送到特定聊天(例如 https://samplechat.firebaseio.com/chats/chat-id/ ),然后他们将不会获得任何其他聊天的任何数据。

关于firebase - 我可以在 Firebase 中实现 channel 的概念吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14863900/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com