Skip to content

Commit

Permalink
#143 use the same writer, remove debug delay
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jun 29, 2024
1 parent 0030fad commit 5162220
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const FILE_SIZE_LIMIT = 4 * 1024 * 1024 * 1024; //are we even allowed to allocat
const FILE_CHUNKS_SIZE = 128 * 1024;
const MAX_CONCURRENT_FILES = 5;
const CHUNK_TIMEOUT = 10 * 1000;
const WEBTRANSPORT = false;
const WEBTRANSPORT = true;

const TEXT_PLAIN = "text/plain";
const UTF8_STRING = "UTF8_STRING";
Expand Down
4 changes: 4 additions & 0 deletions html5/js/Utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ const Utilities = {
return hex;
},

arrayToHex(buffer) {
return Array.prototype.map.call(buffer, x => ('00' + x.toString(16)).slice(-2)).join('');
},

getPlatformProcessor() {
//mozilla property:
if (navigator.oscpu) {
Expand Down
16 changes: 4 additions & 12 deletions html5/js/WebTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@ class XpraWebTransportProtocol {
this.packet_handler = null;
this.webtransport = null;
this.stream = null;
this.writer = null;
this.raw_packets = [];
this.rQ = []; // Receive queue
this.sQ = []; // Send queue
this.mQ = []; // Worker message queue
this.header = [];

//Queue processing via intervals
this.process_interval = 1000; //milliseconds
}

close_event_str(event) {
// TODO: re-use websocket `code_mappings`?
return ""+event;
this.process_interval = 0; //milliseconds
}

cancel_connected_timer() {
Expand Down Expand Up @@ -97,14 +93,11 @@ class XpraWebTransportProtocol {
console.error("error in read loop: "+e);
handle(["close", "read loop error", e.toString()])
});
this.writer = this.stream.writable.getWriter();
handle(["open"]);
console.log("async open end");
}

toHex(buffer) {
return Array.prototype.map.call(buffer, x => ('00' + x.toString(16)).slice(-2)).join('');
}

async read_loop() {
const reader = this.stream.readable.getReader();
const me = this;
Expand All @@ -113,7 +106,6 @@ class XpraWebTransportProtocol {
if (done) {
break;
}
console.log("received: ", this.toHex(value));
this.rQ.push(value);
setTimeout(() => me.process_receive_queue(), this.process_interval);
}
Expand Down Expand Up @@ -335,7 +327,7 @@ class XpraWebTransportProtocol {
}
packet_data.set(bdata, 8);
if (this.stream) {
this.stream.writable.getWriter().write(new Uint8Array(packet_data).buffer);
this.writer.write(new Uint8Array(packet_data).buffer);
}
}
}
Expand Down

0 comments on commit 5162220

Please sign in to comment.