- Fix buffers out of order issue with Transfer system

- Remove debug
- Add cap invocation rate limiter (need to work out which caps require this)
- Fix initial login timing out after just one second
This commit is contained in:
Casper Warden
2018-11-03 14:39:20 +00:00
parent da4cd459f1
commit 65e3aef3f9
4 changed files with 40 additions and 5 deletions

View File

@@ -215,7 +215,7 @@ export class Bot
Code: circuit.circuitCode
};
await circuit.waitForAck(circuit.sendMessage(msg, PacketFlags.Reliable), 1000);
await circuit.waitForAck(circuit.sendMessage(msg, PacketFlags.Reliable), 10000);
const agentMovement: CompleteAgentMovementMessage = new CompleteAgentMovementMessage();

View File

@@ -11,6 +11,8 @@ import {HTTPAssets} from '..';
export class Caps
{
static CAP_INVOCATION_INTERVAL_MS = 250;
private region: Region;
private onGotSeedCap: Subject<void> = new Subject<void>();
private gotSeedCap = false;
@@ -18,6 +20,7 @@ export class Caps
private clientEvents: ClientEvents;
private agent: Agent;
private active = false;
private capRateLimitTimers: {[key: string]: number} = {};
eventQueueClient: EventQueueClient | null = null;
constructor(agent: Agent, region: Region, seedURL: string, clientEvents: ClientEvents)
@@ -300,14 +303,39 @@ export class Caps
});
}
private waitForCapTimeout(cap: string): Promise<void>
{
return new Promise((resolve, reject) =>
{
const timeToWait = (this.capRateLimitTimers[cap] + Caps.CAP_INVOCATION_INTERVAL_MS) - (new Date().getTime());
if (timeToWait > 0)
{
setTimeout(() =>
{
resolve();
}, timeToWait);
}
else
{
resolve();
}
});
}
capsRequestXML(capability: string, data: any, debug = false): Promise<any>
{
if (debug)
{
console.log(data);
}
return new Promise<any>((resolve, reject) =>
return new Promise<any>(async (resolve, reject) =>
{
const t = new Date().getTime();
if (this.capRateLimitTimers[capability] && (this.capRateLimitTimers[capability] + Caps.CAP_INVOCATION_INTERVAL_MS) > t)
{
await this.waitForCapTimeout(capability);
}
this.capRateLimitTimers[capability] = t;
this.getCapability(capability).then((url) =>
{
const xml = LLSD.LLSD.formatXML(data);

View File

@@ -136,7 +136,6 @@ export class AssetCommands extends CommandsBase
}
case Message.TransferAbort:
{
console.log('GOT TRANSFERABORT');
const messg = packet.message as TransferAbortMessage;
if (!messg.TransferInfo.TransferID.equals(transferID))
{
@@ -155,7 +154,10 @@ export class AssetCommands extends CommandsBase
}
if (gotSize >= expectedSize)
{
const packetNumbers = Object.keys(packets).sort();
const packetNumbers = Object.keys(packets).sort((a: string, b: string): number =>
{
return parseInt(a, 10) - parseInt(b, 10);
});
const buffers = [];
for (const pn of packetNumbers)
{

View File

@@ -399,7 +399,7 @@ export class RegionCommands extends CommandsBase
if (objs[ky] !== undefined)
{
const o = objs[ky];
if (o.FullID !== undefined && o.name !== undefined && o.Flags !== undefined && !(o.Flags & PrimFlags.InventoryEmpty) && (!o.inventory || o.inventory.length === 0))
if ((o.resolveAttempts === undefined || o.resolveAttempts < 3) && o.FullID !== undefined && o.name !== undefined && o.Flags !== undefined && !(o.Flags & PrimFlags.InventoryEmpty) && (!o.inventory || o.inventory.length === 0))
{
console.log(' ... Downloading task inventory for object ' + o.FullID.toString() + ' (' + o.name + '), done ' + count + ' of ' + objectSet.length);
const req = new RequestTaskInventoryMessage();
@@ -670,6 +670,11 @@ export class RegionCommands extends CommandsBase
}
catch (error)
{
if (o.resolveAttempts === undefined)
{
o.resolveAttempts = 0;
}
o.resolveAttempts++;
if (o.FullID !== undefined)
{
console.error('Error downloading task inventory of ' + o.FullID.toString() + ':');