logical programming algorithms

0

hi community stackoverflow I hope I will not bore you with so much explanation I will try to be a retailer so that you can understand my problem. I need your help to create an algorithm, I'm not asking you to do my work but rather give me some ideas of how I can achieve what I need to do I explain I have a project in php and > nodejs that I use at the same time and the socket.io library of nodejs for real-time notifications, which send me messages very well and notifications in real time is perfect so to speak up to here all right.

The thing is that I only send messages or notifications to a specific client identified by their session ID of php example when the user starts session if the user entered their correct data on > ajax pick up the session id in a variable var id sends it this way to window.location.href="home.php"+id in the home.php your session is saved in an attribute data of html for example <i id="show_notifications" data-id_user="<?php echo$_GET["id"]?>"> this is the session id of the user that comes from login.php that later will serve me to show notifications in real time I'll explain to you soon how.

An example when I for example like a photo of a user is to execute a javascript code that I sent through socket.io the information of that like for example I send the following data to the server nodejs {id de el usuario al que le di like:id_user,el id de el post al que le di like:post_id } the server nodejs receives that data sends them back and I process them in this way so that the notification comes to that person who gave like example ...

     socket.on("message_from_server",function(data){//listen nodeServer response

            /*la variable actual_user mediante attr captura el id de session actual
               al que se enviara dicha notificacion*/

             var actual_user=$("#show_notifications").attr("data-id_user");

               /*con una condición le decimos que si la variable actual user
                  es igual al id que recibimos de la respuesta de el servidor
                  me ejecute la siguiente instruccion 
                */
                 if(actual_user==data.id_user){

                  /*
                 la etiqueta i que contiene el id show_notifications esta oculta
                 y cuando se ejecuta el código para la notification
                 la mostramos con algunos estilos para que el usuario
                  vea en tiempo real la notifiaction
                  */
                    $("#show_notifications").show();//muestra la etiqueta que contiene la notification
                 }
            })

as you will see the code is not a thing of the other world is simple and works perfectly of course missing more information on some things from the php script and how I get the data I send to nodejs but it is simple I also just did not want to harass them with so much information, now I have the need to send a notification for example to 5, 10,50,100 users at the same time how could I do that? that is, if for example I want to send this notification to all the users that are my followers on my page that I liked "Pedro" for example, how could I implement that basically because I have, for example, 1000 , 2000 or 20,000 followers of how or what would be the best way for me to send a notification of that magnitude with nodejs ? that is my doubt I hope not aya boring with so much explanation thank you and if someone can help me or give me an idea or tips I would appreciate greetings!

    
asked by andy gibbs 20.09.2018 в 20:59
source

0 answers