Second try for #41. I was too enthusiastic to add small tweaks to the code in the original PR, which ended up causing issues. It was very difficult to trace back what the problem was. This PR tries to keep as much as the original logic in tact as possible.
This PR splits the large (1000+ loc) and difficult to maintain app.js into different modules. main.js contains interface logic, and creates a single instance of App (app.js): responsible for retaining players and the selfPlayer. Players already were a separate class, but are put in players.js and now do not own a socket connection, but instead call a delegate method in App. Mediasoup specific logic is isolated in mediasoup-client.js. A Socket class adds our custom async ACK logic to WebSockets. Finally, some totally independent helper methods were moved into utils.js.
This is probably not the best design, but at least a good starting point.
Second try for #41. I was too enthusiastic to add small tweaks to the code in the original PR, which ended up causing issues. It was very difficult to trace back what the problem was. This PR tries to keep as much as the original logic in tact as possible.
This PR splits the large (1000+ loc) and difficult to maintain app.js into different modules. main.js contains interface logic, and creates a single instance of App (app.js): responsible for retaining players and the selfPlayer. Players already were a separate class, but are put in players.js and now do not own a socket connection, but instead call a delegate method in App. Mediasoup specific logic is isolated in mediasoup-client.js. A Socket class adds our custom async ACK logic to WebSockets. Finally, some totally independent helper methods were moved into utils.js.
This is probably not the best design, but at least a good starting point.