Fix code issues reported by Sonar

This commit is contained in:
Ionut Andrei Oanca 2020-11-23 14:27:54 +01:00
parent 66303bdbe5
commit bbef2197dd
16 changed files with 90 additions and 89 deletions

View file

@ -0,0 +1,39 @@
/**
* Module that manages time syncing with server.
* @module components/syncPlay/core/timeSync/TimeSyncServer
*/
import TimeSync from './TimeSync';
/**
* Class that manages time syncing with server.
*/
class TimeSyncServer extends TimeSync {
constructor(syncPlayManager) {
super(syncPlayManager);
}
/**
* Makes a ping request to the server.
*/
requestPing() {
const apiClient = this.manager.getApiClient();
const requestSent = new Date();
let responseReceived;
return apiClient.getServerTime().then((response) => {
responseReceived = new Date();
return response.json();
}).then((data) => {
const requestReceived = new Date(data.RequestReceptionTime);
const responseSent = new Date(data.ResponseTransmissionTime);
return Promise.resolve({
requestSent: requestSent,
requestReceived: requestReceived,
responseSent: responseSent,
responseReceived: responseReceived
});
});
}
}
export default TimeSyncServer;