Skip to content

Commit

Permalink
Reduce Head Memory Usage
Browse files Browse the repository at this point in the history
Reduce Data Memory Usage
Converting to new comms system
Several Patches
  • Loading branch information
Universal Web committed Jul 9, 2023
1 parent d29c502 commit f7f7274
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 189 deletions.
12 changes: 5 additions & 7 deletions udsp/ask.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,22 @@ export class Ask extends Base {
const streamId = packetIdGenerator.get();
this.request.sid = streamId;
this.packetTemplate.sid = streamId;
this.outgoingSetupPacket.sid = streamId;
this.outgoingSetupPacket.method = method;
this.request.method = method;
this.method = method;
this.id = streamId;
if (data) {
this.request.data = data;
}
if (head) {
this.request.head = head;
}
if (method) {
this.request.method = method;
} else {
this.request.method = 'get';
}
queue.set(streamId, this);
}
complete() {
console.log('Ask complete', this);
if (this.state === 3) {
this.state = 4;
}
this.accept(this);
}
isAsk = true;
Expand Down
49 changes: 12 additions & 37 deletions udsp/reply.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,27 @@ export class Reply extends Base {
const thisReply = this;
const { message } = request;
const { sid } = message;
console.log(source);
// console.log(source);
// // console.log(message);
const {
queue,
packetIdGenerator
} = source;
thisReply.source = function() {
return source;
};
const server = source.server();
thisReply.server = function() {
this.server = function() {
return server;
};
thisReply.packetMaxPayload = server.packetMaxPayload;
thisReply.packetMaxPayloadSafeEstimate = server.packetMaxPayloadSafeEstimate;
thisReply.sid = sid;
thisReply.responsePacketTemplate.sid = sid;
thisReply.response.sid = sid;
queue.set(sid, thisReply);
thisReply.sendPacket = function(config) {
return source.send(config);
};
if (source.lastActive) {
source.lastActive = Date.now();
}
thisReply.received(message);
return thisReply;
this.sid = sid;
this.id = sid;
this.packetTemplate.sid = sid;
this.response.sid = sid;
source.lastActive = Date.now();
queue.set(sid, this);
this.onPacket(message);
}
isReply = true;
async assemble() {
const thisReply = this;
const { serialization } = thisReply;
if (thisReply.totalIncomingPackets === 1) {
thisReply.request = thisReply.incomingPackets[0];
}
const packet = thisReply.incomingPackets[0];
eachArray(thisReply.incomingPackets, (item) => {
if (item.data) {
Buffer.concat([packet.data, item.data]);
}
});
if (serialization === 'struct' || !serialization) {
msgReceived(thisReply.request);
if (thisReply.request.data) {
thisReply.request.data = decode(thisReply.request.data);
}
}
async complete() {
this.state = 1;
await processEvent(this);
}
}
Expand Down
Loading

0 comments on commit f7f7274

Please sign in to comment.