Better to take an average of delay for client smoothing? I do not know, but I will try.

This commit is contained in:
Jeremiah Billmann
2013-06-28 23:18:16 -04:00
parent a2b3ecc4da
commit c6e7dd7813
+1 -1
View File
@@ -177,7 +177,7 @@ window.GarageServerIO = (function (window, socketio) {
});
_socket.on('ping', function(data) {
var newPingDelay = new Date().getTime() - data;
_stateController.clientSmoothing = _options.clientSmoothing ? (_stateController.pingDelay / newPingDelay) : 1;
_stateController.clientSmoothing = _options.clientSmoothing ? ((_stateController.clientSmoothing + (_stateController.pingDelay / newPingDelay)) / 2) : 1;
_stateController.pingDelay = newPingDelay;
if (_options.onPing) {
_options.onPing(_stateController.pingDelay);