diff --git a/lib/classes/ClientEvents.ts b/lib/classes/ClientEvents.ts index d3007e0..16dbd14 100644 --- a/lib/classes/ClientEvents.ts +++ b/lib/classes/ClientEvents.ts @@ -27,6 +27,7 @@ import { ObjectResolvedEvent } from '../events/ObjectResolvedEvent'; import { GameObject } from './public/GameObject'; import { Avatar } from './public/Avatar'; import { BulkUpdateInventoryEvent } from '../events/BulkUpdateInventoryEvent'; +import { InventoryResponseEvent } from '../events/InventoryResponseEvent'; export class ClientEvents { @@ -44,6 +45,7 @@ export class ClientEvents onGroupChatSessionJoin: Subject = new Subject(); onGroupChatAgentListUpdate: Subject = new Subject(); onFriendResponse: Subject = new Subject(); + onInventoryResponse: Subject = new Subject(); onScriptDialog: Subject = new Subject(); onEventQueueStateChange: Subject = new Subject(); onFriendOnline: Subject = new Subject(); diff --git a/lib/classes/Comms.ts b/lib/classes/Comms.ts index 9a04190..757d2a9 100644 --- a/lib/classes/Comms.ts +++ b/lib/classes/Comms.ts @@ -22,6 +22,7 @@ import { FriendResponseEvent } from '../events/FriendResponseEvent'; import { GroupChatEvent } from '../events/GroupChatEvent'; import { ChatEvent } from '../events/ChatEvent'; import { ScriptDialogEvent } from '../events/ScriptDialogEvent'; +import { InventoryResponseEvent } from '../events/InventoryResponseEvent'; export class Comms { @@ -85,9 +86,27 @@ export class Comms break; } case InstantMessageDialog.InventoryAccepted: + { + const irEvent = new InventoryResponseEvent(); + irEvent.from = im.AgentData.AgentID; + irEvent.fromName = Utils.BufferToStringSimple(im.MessageBlock.FromAgentName); + irEvent.message = Utils.BufferToStringSimple(im.MessageBlock.Message); + irEvent.requestID = im.MessageBlock.ID; + irEvent.accepted = true; + this.clientEvents.onInventoryResponse.next(irEvent); break; + } case InstantMessageDialog.InventoryDeclined: + { + const irEvent = new InventoryResponseEvent(); + irEvent.from = im.AgentData.AgentID; + irEvent.fromName = Utils.BufferToStringSimple(im.MessageBlock.FromAgentName); + irEvent.message = Utils.BufferToStringSimple(im.MessageBlock.Message); + irEvent.requestID = im.MessageBlock.ID; + irEvent.accepted = false; + this.clientEvents.onInventoryResponse.next(irEvent); break; + } case InstantMessageDialog.TaskInventoryOffered: { const fromName = Utils.BufferToStringSimple(im.MessageBlock.FromAgentName); diff --git a/lib/events/InventoryResponseEvent.ts b/lib/events/InventoryResponseEvent.ts new file mode 100644 index 0000000..9e15fa2 --- /dev/null +++ b/lib/events/InventoryResponseEvent.ts @@ -0,0 +1,10 @@ +import { UUID } from '../classes/UUID'; + +export class InventoryResponseEvent +{ + from: UUID; + fromName: string; + message: string; + accepted: boolean; + requestID: UUID; +}