How does js maintain an online audience list

the company does live broadcasting related projects. There is a list of online viewers. updates in real time , which is maintained on the page by the front end

.

the current practice is to write a structure with push, remove, sort, sync , responsible for entry, exit, sorting, synchronization.

when someone comes in, push to the end. When you go out, there is only id, so you need to find (). Sorting will be performed during synchronization. There are two strategies for synchronization: one is timing synchronization, and the other is push or remove will perform synchronization.

  1. has already used virtual lists, otherwise tens of thousands of pieces of data will be displayed and the client memory will explode.
  2. one idea is to delete the sort operation, confirm the general location with insertion sorting and bisection retrieval, and then traverse it.

would you like to ask if there are any other optimization points? Or other mature solutions.

Jun.01,2022
Menu