This commit demonstrates how to add a new client command to node-metaverse.

It also shows how to add a new command category (ParcelCommands)

Everything under dist/ is auto-generated with "npm run build".
This commit is contained in:
Casper Warden
2018-10-06 17:18:46 +01:00
parent cb2be348d7
commit ad559567b3
17 changed files with 215 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
import { CommandsBase } from './CommandsBase';
import { UUID } from '../UUID';
import { ParcelInfoReplyEvent } from '../..';
export declare class ParcelCommands extends CommandsBase {
getParcelInfo(parcelID: UUID | string): Promise<ParcelInfoReplyEvent>;
}

60
dist/classes/commands/ParcelCommands.js vendored Normal file
View File

@@ -0,0 +1,60 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const CommandsBase_1 = require("./CommandsBase");
const ParcelInfoRequest_1 = require("../messages/ParcelInfoRequest");
const UUID_1 = require("../UUID");
const Message_1 = require("../../enums/Message");
const FilterResponse_1 = require("../../enums/FilterResponse");
const Utils_1 = require("../Utils");
const __1 = require("../..");
class ParcelCommands extends CommandsBase_1.CommandsBase {
getParcelInfo(parcelID) {
return __awaiter(this, void 0, void 0, function* () {
if (typeof parcelID === 'string') {
parcelID = new UUID_1.UUID(parcelID);
}
const msg = new ParcelInfoRequest_1.ParcelInfoRequestMessage();
msg.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
msg.Data = {
ParcelID: parcelID
};
this.circuit.sendMessage(msg, __1.PacketFlags.Reliable);
const parcelInfoReply = (yield this.circuit.waitForMessage(Message_1.Message.ParcelInfoReply, 10000, (packet) => {
const replyMessage = packet.message;
if (replyMessage.Data.ParcelID.equals(parcelID)) {
return FilterResponse_1.FilterResponse.Match;
}
return FilterResponse_1.FilterResponse.NoMatch;
}));
return new class {
constructor() {
this.OwnerID = parcelInfoReply.Data.OwnerID;
this.ParcelName = Utils_1.Utils.BufferToStringSimple(parcelInfoReply.Data.Name);
this.ParcelDescription = Utils_1.Utils.BufferToStringSimple(parcelInfoReply.Data.Desc);
this.Area = parcelInfoReply.Data.ActualArea;
this.BillableArea = parcelInfoReply.Data.BillableArea;
this.Flags = parcelInfoReply.Data.Flags;
this.GlobalCoordinates = new __1.Vector3([parcelInfoReply.Data.GlobalX, parcelInfoReply.Data.GlobalY, parcelInfoReply.Data.GlobalZ]);
this.RegionName = Utils_1.Utils.BufferToStringSimple(parcelInfoReply.Data.SimName);
this.SnapshotID = parcelInfoReply.Data.SnapshotID;
this.Traffic = parcelInfoReply.Data.Dwell;
this.SalePrice = parcelInfoReply.Data.SalePrice;
this.AuctionID = parcelInfoReply.Data.AuctionID;
}
};
});
}
}
exports.ParcelCommands = ParcelCommands;
//# sourceMappingURL=ParcelCommands.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ParcelCommands.js","sourceRoot":"","sources":["../../../lib/classes/commands/ParcelCommands.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,iDAA4C;AAC5C,qEAAuE;AACvE,kCAA6B;AAC7B,iDAA4C;AAG5C,+DAA0D;AAC1D,oCAA+B;AAC/B,6BAAiE;AAIjE,oBAA4B,SAAQ,2BAAY;IAEtC,aAAa,CAAC,QAAuB;;YAKvC,EAAE,CAAC,CAAC,OAAO,QAAQ,KAAK,QAAQ,CAAC,CACjC,CAAC;gBACG,QAAQ,GAAG,IAAI,WAAI,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;YAGD,MAAM,GAAG,GAA6B,IAAI,4CAAwB,EAAE,CAAC;YAGrE,GAAG,CAAC,SAAS,GAAG;gBACZ,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;gBAC3B,SAAS,E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oBAC5H,eAAU,GAAI,aAAK,CAAC,oBAAoB,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACvE,eAAU,GAAG,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC;oBAC7C,YAAO,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC;oBACrC,cAAS,GAAG,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC;oBAC3C,cAAS,GAAG,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC;gBAC/C,CAAC;aAAA,CAAC;QACN,CAAC;KAAA;CACJ;AAlED,wCAkEC"}

3
dist/enums/ParcelInfoFlags.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare enum ParcelInfoFlags {
mature = 1,
}

7
dist/enums/ParcelInfoFlags.js vendored Normal file
View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ParcelInfoFlags;
(function (ParcelInfoFlags) {
ParcelInfoFlags[ParcelInfoFlags["mature"] = 1] = "mature";
})(ParcelInfoFlags = exports.ParcelInfoFlags || (exports.ParcelInfoFlags = {}));
//# sourceMappingURL=ParcelInfoFlags.js.map

1
dist/enums/ParcelInfoFlags.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ParcelInfoFlags.js","sourceRoot":"","sources":["../../lib/enums/ParcelInfoFlags.ts"],"names":[],"mappings":";;AAAA,IAAY,eAGX;AAHD,WAAY,eAAe;IAEvB,yDAAe,CAAA;AACnB,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B"}

15
dist/events/ParcelInfoReplyEvent.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
import { ParcelInfoFlags, UUID, Vector3 } from '..';
export declare class ParcelInfoReplyEvent {
OwnerID: UUID;
ParcelName: string;
ParcelDescription: string;
Area: number;
BillableArea: number;
Flags: ParcelInfoFlags;
GlobalCoordinates: Vector3;
RegionName: string;
SnapshotID: UUID;
Traffic: number;
SalePrice: number;
AuctionID: number;
}

6
dist/events/ParcelInfoReplyEvent.js vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ParcelInfoReplyEvent {
}
exports.ParcelInfoReplyEvent = ParcelInfoReplyEvent;
//# sourceMappingURL=ParcelInfoReplyEvent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ParcelInfoReplyEvent.js","sourceRoot":"","sources":["../../lib/events/ParcelInfoReplyEvent.ts"],"names":[],"mappings":";;AAEA;CAcC;AAdD,oDAcC"}

4
dist/index.d.ts vendored
View File

@@ -35,4 +35,6 @@ import { SoundFlags } from './enums/SoundFlags';
import { TeleportFlags } from './enums/TeleportFlags';
import { CompressedFlags } from './enums/CompressedFlags';
import { DecodeFlags } from './enums/DecodeFlags';
export { Bot, LoginParameters, AssetType, HTTPAssets, ClientEvents, BVH, ChatSourceType, BotOptionFlags, UUID, Vector3, AgentFlags, CompressedFlags, ControlFlags, DecodeFlags, InstantMessageEventFlags, InventoryItemFlags, LoginFlags, MessageFlags, PacketFlags, RegionProtocolFlags, SoundFlags, TeleportFlags, ChatEvent, DisconnectEvent, FriendRequestEvent, FriendResponseEvent, GroupChatEvent, GroupChatSessionAgentListEvent, GroupChatSessionJoinEvent, GroupInviteEvent, InstantMessageEvent, InventoryOfferedEvent, LureEvent, MapInfoRangeReplyEvent, MapInfoReplyEvent, RegionInfoReplyEvent, TeleportEvent };
import { ParcelInfoFlags } from './enums/ParcelInfoFlags';
import { ParcelInfoReplyEvent } from './events/ParcelInfoReplyEvent';
export { Bot, LoginParameters, AssetType, HTTPAssets, ClientEvents, BVH, ChatSourceType, BotOptionFlags, UUID, Vector3, AgentFlags, CompressedFlags, ControlFlags, DecodeFlags, InstantMessageEventFlags, InventoryItemFlags, LoginFlags, MessageFlags, ParcelInfoFlags, PacketFlags, RegionProtocolFlags, SoundFlags, TeleportFlags, ChatEvent, DisconnectEvent, FriendRequestEvent, FriendResponseEvent, GroupChatEvent, GroupChatSessionAgentListEvent, GroupChatSessionJoinEvent, GroupInviteEvent, InstantMessageEvent, InventoryOfferedEvent, LureEvent, MapInfoRangeReplyEvent, MapInfoReplyEvent, ParcelInfoReplyEvent, RegionInfoReplyEvent, TeleportEvent };

4
dist/index.js vendored
View File

@@ -74,4 +74,8 @@ const CompressedFlags_1 = require("./enums/CompressedFlags");
exports.CompressedFlags = CompressedFlags_1.CompressedFlags;
const DecodeFlags_1 = require("./enums/DecodeFlags");
exports.DecodeFlags = DecodeFlags_1.DecodeFlags;
const ParcelInfoFlags_1 = require("./enums/ParcelInfoFlags");
exports.ParcelInfoFlags = ParcelInfoFlags_1.ParcelInfoFlags;
const ParcelInfoReplyEvent_1 = require("./events/ParcelInfoReplyEvent");
exports.ParcelInfoReplyEvent = ParcelInfoReplyEvent_1.ParcelInfoReplyEvent;
//# sourceMappingURL=index.js.map

2
dist/index.js.map vendored
View File

@@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;AAAA,+BAA0B;AA2CtB,cA3CI,SAAG,CA2CJ;AA1CP,+DAA0D;AA2CtD,0BA3CI,iCAAe,CA2CJ;AA1CnB,yDAAoD;AA6ChD,uBA7CI,2BAAY,CA6CJ;AA5ChB,uCAAkC;AA6C9B,cA7CI,SAAG,CA6CJ;AAxCP,iDAA4C;AAqCxC,oBArCI,qBAAS,CAqCJ;AApCb,mDAA8C;AAqC1C,qBArCI,uBAAU,CAqCJ;AApCd,+EAA0E;AAiDtE,mCAjDI,mDAAwB,CAiDJ;AAhD5B,sEAAiE;AAkE7D,8BAlEI,yCAAmB,CAkEJ;AAjEvB,2DAAsD;AAqClD,yBArCI,+BAAc,CAqCJ;AApClB,2DAAsD;AAqClD,yBArCI,+BAAc,CAqCJ;AApClB,yCAAoC;AAqChC,eArCI,WAAI,CAqCJ;AApCR,+CAA0C;AAqCtC,kBArCI,iBAAO,CAqCJ;AApCX,kDAA6C;AAqDzC,oBAr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AAsB,CAuDJ;AAtD1B,0EAAqE;AAoDjE,gCApDI,6CAAqB,CAoDJ;AAnDzB,mDAA8C;AA2B1C,qBA3BI,uBAAU,CA2BJ;AA1Bd,uDAAkD;AA4B9C,uBA5BI,2BAAY,CA4BJ;AA3BhB,mEAA8D;AA8B1D,6BA9BI,uCAAkB,CA8BJ;AA7BtB,mDAA8C;AA8B1C,qBA9BI,uBAAU,CA8BJ;AA7Bd,uDAAkD;AA8B9C,uBA9BI,2BAAY,CA8BJ;AA7BhB,qDAAgD;AA+B5C,sBA/BI,yBAAW,CA+BJ;AA9Bf,qEAAgE;AA+B5D,8BA/BI,yCAAmB,CA+BJ;AA9BvB,mDAA8C;AA+B1C,qBA/BI,uBAAU,CA+BJ;AA9Bd,yDAAoD;AA+BhD,wBA/BI,6BAAa,CA+BJ;AA9BjB,6DAAwD;AAmBpD,0BAnBI,iCAAe,CAmBJ;AAlBnB,qDAAgD;AAoB5C,sBApBI,yBAAW,CAoBJ;AAnBf,6DAAwD;AAwBpD,0BAxBI,iCAAe,CAwBJ;AAvBnB,wEAAmE;AA2C/D,+BA3CI,2CAAoB,CA2CJ"}

View File

@@ -10,6 +10,7 @@ import {CommunicationsCommands} from './commands/CommunicationsCommands';
import {AgentCommands} from './commands/AgentCommands';
import {GroupCommands} from './commands/GroupCommands';
import {InventoryCommands} from './commands/InventoryCommands';
import {ParcelCommands} from './commands/ParcelCommands';
export class ClientCommands
{
@@ -17,6 +18,7 @@ export class ClientCommands
public asset: AssetCommands;
public teleport: TeleportCommands;
public region: RegionCommands;
public parcel: ParcelCommands;
public grid: GridCommands;
public comms: CommunicationsCommands;
public agent: AgentCommands;
@@ -29,6 +31,7 @@ export class ClientCommands
this.asset = new AssetCommands(region, agent, bot);
this.teleport = new TeleportCommands(region, agent, bot);
this.region = new RegionCommands(region, agent, bot);
this.parcel = new ParcelCommands(region, agent, bot);
this.grid = new GridCommands(region, agent, bot);
this.comms = new CommunicationsCommands(region, agent, bot);
this.agent = new AgentCommands(region, agent, bot);

View File

@@ -0,0 +1,79 @@
import {CommandsBase} from './CommandsBase';
import {ParcelInfoRequestMessage} from '../messages/ParcelInfoRequest';
import {UUID} from '../UUID';
import {Message} from '../../enums/Message';
import {ParcelInfoReplyMessage} from '../messages/ParcelInfoReply';
import {Packet} from '../Packet';
import {FilterResponse} from '../../enums/FilterResponse';
import {Utils} from '../Utils';
import {PacketFlags, ParcelInfoReplyEvent, Vector3} from '../..';
// This class was added to provide a new "Category" of commands, since we don't have any parcel specific functionality yet.
export class ParcelCommands extends CommandsBase
{
async getParcelInfo(parcelID: UUID | string): Promise<ParcelInfoReplyEvent>
{
// Since this is a userspace command, we are kind and accept the UUID as a string.
// If it's a string, then we convert to UUID.
if (typeof parcelID === 'string')
{
parcelID = new UUID(parcelID);
}
// Create a new ParcelInfoRequest message, which is the type that we want
const msg: ParcelInfoRequestMessage = new ParcelInfoRequestMessage();
// Fill the message with the correct data (see ParcelInfoRequest.ts)
msg.AgentData = {
AgentID: this.agent.agentID,
SessionID: this.circuit.sessionID
};
msg.Data = {
ParcelID: parcelID
};
// Shove the message into our send queue
this.circuit.sendMessage(msg, PacketFlags.Reliable);
// And wait for a reply. It's okay to do this after we send since we haven't yielded until this subscription is set up.
const parcelInfoReply: ParcelInfoReplyMessage = (await this.circuit.waitForMessage(Message.ParcelInfoReply, 10000, (packet: Packet): FilterResponse =>
{
// This function is here as a filter to ensure we get the correct message.
// It compares every incoming ParcelInfoReplyMessage, checks the ParcelID and compares to the one we requested.
const replyMessage: ParcelInfoReplyMessage = packet.message as ParcelInfoReplyMessage;
if (replyMessage.Data.ParcelID.equals(parcelID))
{
// We received a reply for the ParcelID that we requested info for, so return with "Finish" because we don't want any more after this.
// If we are expecting multiple replies we can reply with FilterResponse.Match which will keep the listener open.
return FilterResponse.Match;
}
return FilterResponse.NoMatch;
})) as ParcelInfoReplyMessage;
// parcelInfoReply will now contain the message that we issued a "Finish" response for.
// In the event of an error or timeout, an exception would have been thrown and this code won't be reached.
// Rather than simply returning the message, we convert the data into an "Event" which is supposed to be
// a bit more user friendly for the user.
return new class implements ParcelInfoReplyEvent
{
OwnerID = parcelInfoReply.Data.OwnerID;
// Because Data.Name is a buffer, we have a halper functino to decode it.
ParcelName = Utils.BufferToStringSimple(parcelInfoReply.Data.Name);
ParcelDescription = Utils.BufferToStringSimple(parcelInfoReply.Data.Desc);
Area = parcelInfoReply.Data.ActualArea;
BillableArea = parcelInfoReply.Data.BillableArea;
Flags = parcelInfoReply.Data.Flags;
GlobalCoordinates = new Vector3([parcelInfoReply.Data.GlobalX, parcelInfoReply.Data.GlobalY, parcelInfoReply.Data.GlobalZ]);
RegionName = Utils.BufferToStringSimple(parcelInfoReply.Data.SimName);
SnapshotID = parcelInfoReply.Data.SnapshotID;
Traffic = parcelInfoReply.Data.Dwell;
SalePrice = parcelInfoReply.Data.SalePrice;
AuctionID = parcelInfoReply.Data.AuctionID;
};
}
}

View File

@@ -0,0 +1,4 @@
export enum ParcelInfoFlags
{
mature = 1 << 0
}

View File

@@ -0,0 +1,17 @@
import {ParcelInfoFlags, UUID, Vector3} from '..';
export class ParcelInfoReplyEvent
{
OwnerID: UUID;
ParcelName: string;
ParcelDescription: string;
Area: number;
BillableArea: number;
Flags: ParcelInfoFlags;
GlobalCoordinates: Vector3;
RegionName: string;
SnapshotID: UUID;
Traffic: number;
SalePrice: number;
AuctionID: number;
}

View File

@@ -39,6 +39,8 @@ import {SoundFlags} from './enums/SoundFlags';
import {TeleportFlags} from './enums/TeleportFlags';
import {CompressedFlags} from './enums/CompressedFlags';
import {DecodeFlags} from './enums/DecodeFlags';
import {ParcelInfoFlags} from './enums/ParcelInfoFlags';
import {ParcelInfoReplyEvent} from './events/ParcelInfoReplyEvent';
export {
Bot,
@@ -61,6 +63,7 @@ export {
InventoryItemFlags,
LoginFlags,
MessageFlags,
ParcelInfoFlags,
PacketFlags,
RegionProtocolFlags,
SoundFlags,
@@ -80,6 +83,7 @@ export {
LureEvent,
MapInfoRangeReplyEvent,
MapInfoReplyEvent,
ParcelInfoReplyEvent,
RegionInfoReplyEvent,
TeleportEvent
};