0

Broadcast an event between different sessions opened by different users in AngularJS

I am working on an application that can be used by multiple users in angularJS. When I (user A) assign a new task to a different user (user B), I broadcast an event. However, as user B is logged in a different browser and has a different session, that event is broadcasted just for user A.

How can I broadcast the event to all the different users (sessions) using my website?

One way of doing this was having an interval of 10 seconds and updating the data, but that is not efficient.

That's why what I am looking for is a way to broadcast and even from user A's session and on receiving it in user B's session, update the view!

Any help is appreciated!

Community
  • 1
  • 1
Pranav Bhatia
  • 155
  • 4
  • 14
  • 1
    This will be done through the server – Jaromanda X Apr 16 '19 at 00:28
  • Yes, this cannot be a pure client side implementation, see SignalR for example for realtime broadcasting of events from the server side to 1 to many clients, among many other possibilities – Luke Hutton Apr 16 '19 at 00:40
  • 1
    In case of NodeJS as the backend, do you mean using Socket IO? – Pranav Bhatia Apr 16 '19 at 01:06
  • Yes, you could use that library to perform what you describe above – Luke Hutton Apr 16 '19 at 01:08
  • Is there any other way (better way) to achieve this? – Pranav Bhatia Apr 16 '19 at 01:36
  • better is subjective, I think using an existing lib such as Socket IO is reasonable for your requirements, they are all fairly similar, you could produce list of pros and cons of other libs, and then decide yourself – Luke Hutton Apr 16 '19 at 01:41
  • 1
    Possible duplicate of [WebSockets vs. Server-Sent events/EventSource](https://stackoverflow.com/questions/5195452/websockets-vs-server-sent-events-eventsource/5326159#5326159). – georgeawg Apr 16 '19 at 02:35

0 Answers0