this.imageMimeType = this.format === 'jpg' ? 'image/jpeg' : 'image/png';
this._needSeparateTextures = [];
this.loadbalancing = false;
- this._loadbalancingServerURL = [];
+ this._loadbalancingServerURL = {};
}
FluidbookLoader.prototype = {
init: function (callback) {
let $this = this;
if (this.fluidbook.settings.hosting_loadbalancer) {
+ this._loadbalancingServerURL = this.fluidbook.cache.get('_loadbalancingServerURL', {});
+ setInterval(function () {
+ $this.fluidbook.cache.set('_loadbalancingServerURL', $this._loadbalancingServerURL);
+ }, 15000);
$.ajax("https://toolbox.fluidbook.com/lb.json").done(function (data) {
$this.loadbalancing = data;
$this.loadShades(callback);
preloadStart: function (callback) {
let $this = this;
this.init(function () {
- $this.fluidbook.sound.preloadSounds();
+ if($this.fluidbook.sound.enabled) {
+ $this.fluidbook.sound.preloadSounds();
+ }
if ($this.fluidbook.shortLoading) {
$this.toPreload = [1];
} else {
if (!this.loadbalancing) {
return url;
}
- if(this._loadbalancingServerURL[url]===undefined){
- this._loadbalancingServerURL[url]=this.loadbalancing[Math.floor(Math.random() * this.loadbalancing.length)];
+
+ if (this._loadbalancingServerURL[url] === undefined || this.loadbalancing.indexOf(this._loadbalancingServerURL[url]) >= 0) {
+ this._loadbalancingServerURL[url] = this.loadbalancing[Math.floor(Math.random() * this.loadbalancing.length)];
}
return 'https://' + this._loadbalancingServerURL[url] + '/' + this.fluidbook.settings.id + '_' + this.fluidbook.settings.hash + '/' + url;
},