Ping / circuit latency, break out commands, add typing function for IM, add thinkingTime and charactersPerSecond parameters to typing functions

This commit is contained in:
Casper Warden
2017-12-13 19:55:08 +00:00
parent af71aa597e
commit 4e8feb181f
96 changed files with 2151 additions and 935 deletions

View File

@@ -0,0 +1,50 @@
import {CommandsBase} from './CommandsBase';
import {HTTPAssets} from '../../enums/HTTPAssets';
import {UUID} from '../UUID';
import * as LLSD from 'llsd';
import {Utils} from '../Utils';
export class AssetCommands extends CommandsBase
{
downloadAsset(type: HTTPAssets, uuid: UUID)
{
return this.currentRegion.caps.downloadAsset(uuid, type);
}
uploadAsset(type: HTTPAssets, data: Buffer, name: string, description: string): Promise<UUID>
{
return new Promise<UUID>((resolve, reject) =>
{
if (this.agent && this.agent.inventory && this.agent.inventory.main && this.agent.inventory.main.root)
{
this.currentRegion.caps.capsRequestXML('NewFileAgentInventory', {
'folder_id': new LLSD.UUID(this.agent.inventory.main.root.toString()),
'asset_type': type,
'inventory_type': Utils.HTTPAssetTypeToInventoryType(type),
'name': name,
'description': description,
'everyone_mask': (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19),
'group_mask': (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19),
'next_owner_mask': (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19),
'expected_upload_cost': 0
}).then((response: any) =>
{
if (response['state'] === 'upload')
{
const uploadURL = response['uploader'];
this.currentRegion.caps.capsRequestUpload(uploadURL, data).then((responseUpload: any) =>
{
resolve(new UUID(responseUpload['new_asset'].toString()));
}).catch((err) =>
{
reject(err);
});
}
}).catch((err) =>
{
console.log(err);
})
}
});
}
}