Ticket #1424: html5-timers-managed.patch
File html5-timers-managed.patch, 2.9 KB (added by , 4 years ago) |
---|
-
html5/js/Protocol.js
122 122 this.websocket.onmessage = function (e) { 123 123 // push arraybuffer values onto the end 124 124 me.rQ.push(new Uint8Array(e.data)); 125 if (me.rQ_interval_id === null) { 126 me.rQ_interval_id = setInterval(function() { 127 me.process_receive_queue(); 128 }, this.process_interval); 129 } 125 130 }; 126 131 this.start_processing(); 127 132 } … … 139 144 } 140 145 141 146 XpraProtocol.prototype.start_processing = function() { 142 var me = this;143 if(this.rQ_interval_id === null){144 this.rQ_interval_id = setInterval(function(){145 if (me.rQ.length > 0) {146 me.process_receive_queue();147 }148 }, this.process_interval);149 }150 151 if(this.sQ_interval_id === null){152 this.sQ_interval_id = setInterval(function(){153 if(me.sQ.length > 0){154 me.process_send_queue();155 }156 }, this.process_interval);157 }158 159 if(this.mQ_interval_id === null){160 this.mQ_interval_id = setInterval(function(){161 if(me.mQ.length > 0){162 me.process_message_queue();163 }164 }, this.process_interval);165 }166 147 } 167 148 XpraProtocol.prototype.stop_processing = function() { 168 149 clearInterval(this.rQ_interval_id); … … 177 158 178 159 179 160 XpraProtocol.prototype.process_receive_queue = function() { 161 if (this.rQ.length === 0) { 162 clearInterval(this.rQ_interval_id); 163 this.rQ_interval_id = null; 164 return; 165 } 166 180 167 var i = 0, j = 0; 181 168 if (this.header.length<8 && this.rQ.length>0) { 182 169 //add from receive queue data to header until we get the 8 bytes we need: … … 349 336 } 350 337 if (this.is_worker){ 351 338 this.mQ[this.mQ.length] = packet; 339 if(this.mQ_interval_id === null){ 340 var me = this; 341 this.mQ_interval_id = setInterval(function() { 342 me.process_message_queue(); 343 }, this.process_interval); 344 } 352 345 } else { 353 346 this.packet_handler(packet, this.packet_ctx); 354 347 } … … 360 353 } 361 354 362 355 // see if buffer still has unread packets 363 if (this.rQ.length > 0) { 364 this.process_receive_queue(); 356 if (this.rQ.length === 0) { 357 clearInterval(this.rQ_interval_id); 358 this.rQ_interval_id = null; 365 359 } 366 360 } 367 361 368 362 XpraProtocol.prototype.process_send_queue = function() { 363 clearInterval(this.sQ_interval_id); 364 this.sQ_interval_id = null; 369 365 while(this.sQ.length !== 0) { 370 366 var packet = this.sQ.shift(); 371 367 if(!packet){ … … 412 408 } 413 409 414 410 XpraProtocol.prototype.process_message_queue = function() { 411 clearInterval(this.mQ_interval_id); 412 this.mQ_interval_id = null; 415 413 while(this.mQ.length !== 0){ 416 414 var packet = this.mQ.shift(); 417 415 … … 426 424 427 425 XpraProtocol.prototype.send = function(packet) { 428 426 this.sQ[this.sQ.length] = packet; 427 if(this.sQ_interval_id === null){ 428 var me = this; 429 this.sQ_interval_id = setInterval(function() { 430 me.process_send_queue(); 431 }, this.process_interval); 432 } 429 433 } 430 434 431 435 XpraProtocol.prototype.set_packet_handler = function(callback, ctx) {