I have a web app in which a teacher creates a class and is able to upload materials and add students to the class. Students can also join a particular teacher's class and download any uploaded material.
When a teacher uploads a material to a particular class, a Server Sent Event is sent to every connected client and from the client, checks are performed to find out if this event concerns the client. Here's a code sample:
let eventSource = new EventSource(url);
eventSource.onmessage = function(event){
if(joinedClasses.indexOf(event.data.class) !== -1){
//notify the user.
}
//else just discard the message.
}
I want to know if this is the proper way of doing this or should I just use (Long) Polling or some other method. Thanks.