一次仅一次向一个用户

一次仅一次向一个用户

本文介绍了一次仅一次向一个用户(而不是通道)实时推送更新。怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Web应用程序/站点,我的服务器将在其中将实时更新推送到客户端一些信息(使用Pusher api)。



因此,当服务器将更新推送到该频道时,订阅频道的用户可以接收更新。



但是,(由于我的应用程序的性质)应该只有一个一次接收实时更新的USER。换句话说,更新实际上不是针对特定的频道,而是特定的用户。



我当前的解决方案是:
每个频道仅允许一个用户因此,针对CHANNEL的更新是针对该用户的。假设我有500个用户,那么我需要有500个频道。
这需要设置很多渠道。这会影响性能吗?



还有更好的方法吗?



========= ======



应用程序背景



该应用程序用于接收有关灾难的报告并分配一个最近的代理机构来接手并处理情况。每个代理商都将是系统的用户(将获得用户名)。
服务器收到报告后,最近的(只有一个)用户(从提交报告的位置开始)将收到来自服务器的实时通知。

解决方案

当前除了向每个用户提供频道外,没有其他方法可以向用户发送消息。




这听起来就像您现在正在使用的解决方案,例如频道和用户-可以通过频道名称唯一标识:



< user_name>-通知



由于通道只是一种路由机制,因此拥有大量通道并没有真正的开销;当然500根本不会有问题。



我假设您正在使用,以确保只有允许的用户才能订阅其频道。


I'm creating a web app/site in which my server will push real-time update to clients some info (using Pusher api).

So, the USERS that subscribe to a CHANNEL can receive the update when the server pushes updates to this CHANNEL.

However, (because of the nature of my application) there should be only one USER that receive a real-time update at a time. In other words, an update is actually targeted to not a specific CHANNEL, but a specific USER.

My current solution is:Each CHANNEL allows only one USER so the update targeted to the CHANNEL is for that one USER. Suppose I have 500 users then I need to have 500 channels.This requires setting up a lot of channels. Does that affect performance?

Is there any better way?

===============

App Background

The app is about receiving report about a disaster and assigning a nearest agency to take over and handle the situation. Each agency will be a user of the system (will be given a username).When the server receives a report, the nearest - only one - user (from the location where the report is lodged) will receive a real-time notification from the server.

解决方案

At the moment there is not way to send a message to a user other than to have a channel per user.

This sounds exactly like the solution you are using right now e.g. the channel - and user - can be uniquely identified by channel name:

<user_name>-notification

Since channels are simply a routing mechanism there is no real overhead in having lots of channels; certainly 500 won't be any problem at all.

I'm assuming you are using private channels to ensure that only the allowed user can subscribe to their channel.

这篇关于一次仅一次向一个用户(而不是通道)实时推送更新。怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 05:51