arangace / CreamCat

SOFTENG750 project team CreamCat
MIT License
0 stars 3 forks source link

Emit messages to server to execute logic on song end #51

Closed arangace closed 3 years ago

arangace commented 3 years ago

Certain player events should trigger an emit message from the client to the server and cause the backend to execute certain logic.

nivekyee commented 3 years ago

@arangace @sjun521 @Akunda-p

On song end, implementing extra logic on the server/database to only operate on the first "song end" message received is redundant and impossible.

To check whether a "song end" message is the first instance received:

  1. A songEnded field will need to be defined and set in the database, which means a mongoose call will need to be made everytime a "song end" message is received in order to fetch the field, which is no quicker than attempting a mongoose call to delete a song and failing.
  2. The first "song end" message triggers a deletion event on the backend, therefore no subsequent "song end" messages of the same song will be able to run properly with the song already being deleted.

The only way to reduce server load is to prevent clients from emitting a message to the server.

This brings me to think, instead of deleting the song from the backend on a socket listener,