Create group chat session on send, if it doesn't exist
This commit is contained in:
3
dist/classes/Agent.d.ts
vendored
3
dist/classes/Agent.d.ts
vendored
@@ -17,6 +17,7 @@ export declare class Agent {
|
||||
regionAccess: string;
|
||||
agentAccess: string;
|
||||
currentRegion: Region;
|
||||
chatSessions: string[];
|
||||
controlFlags: ControlFlags;
|
||||
openID: {
|
||||
'token'?: string;
|
||||
@@ -55,6 +56,8 @@ export declare class Agent {
|
||||
agentUpdateTimer: number | null;
|
||||
private clientEvents;
|
||||
constructor(clientEvents: ClientEvents);
|
||||
addChatSession(uuid: UUID): void;
|
||||
hasChatSession(uuid: UUID): boolean;
|
||||
setCurrentRegion(region: Region): void;
|
||||
circuitActive(): void;
|
||||
sendAgentUpdate(): void;
|
||||
|
||||
14
dist/classes/Agent.js
vendored
14
dist/classes/Agent.js
vendored
@@ -21,6 +21,7 @@ const Utils_1 = require("./Utils");
|
||||
class Agent {
|
||||
constructor(clientEvents) {
|
||||
this.localID = 0;
|
||||
this.chatSessions = [];
|
||||
this.controlFlags = 0;
|
||||
this.openID = {};
|
||||
this.buddyList = [];
|
||||
@@ -31,6 +32,19 @@ class Agent {
|
||||
this.inventory = new Inventory_1.Inventory(clientEvents);
|
||||
this.clientEvents = clientEvents;
|
||||
}
|
||||
addChatSession(uuid) {
|
||||
const str = uuid.toString();
|
||||
if (this.chatSessions.indexOf(str) === -1) {
|
||||
this.chatSessions.push(str);
|
||||
}
|
||||
}
|
||||
hasChatSession(uuid) {
|
||||
const str = uuid.toString();
|
||||
if (this.chatSessions.indexOf(str) === -1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
setCurrentRegion(region) {
|
||||
this.currentRegion = region;
|
||||
this.currentRegion.circuit.subscribeToMessages([
|
||||
|
||||
2
dist/classes/Agent.js.map
vendored
2
dist/classes/Agent.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/classes/Caps.d.ts
vendored
4
dist/classes/Caps.d.ts
vendored
@@ -4,14 +4,16 @@ import { EventQueueClient } from './EventQueueClient';
|
||||
import { UUID } from './UUID';
|
||||
import { HTTPAssets } from '../enums/HTTPAssets';
|
||||
import { ClientEvents } from "./ClientEvents";
|
||||
import { Agent } from './Agent';
|
||||
export declare class Caps {
|
||||
private region;
|
||||
private onGotSeedCap;
|
||||
private gotSeedCap;
|
||||
private capabilities;
|
||||
private clientEvents;
|
||||
private agent;
|
||||
eventQueueClient: EventQueueClient | null;
|
||||
constructor(region: Region, seedURL: string, clientEvents: ClientEvents);
|
||||
constructor(agent: Agent, region: Region, seedURL: string, clientEvents: ClientEvents);
|
||||
downloadAsset(uuid: UUID, type: HTTPAssets): Promise<Buffer>;
|
||||
request(url: string, data: string | Buffer, contentType: string): Promise<string>;
|
||||
waitForSeedCapability(): Promise<void>;
|
||||
|
||||
5
dist/classes/Caps.js
vendored
5
dist/classes/Caps.js
vendored
@@ -5,11 +5,12 @@ const request = require("request");
|
||||
const Subject_1 = require("rxjs/Subject");
|
||||
const EventQueueClient_1 = require("./EventQueueClient");
|
||||
class Caps {
|
||||
constructor(region, seedURL, clientEvents) {
|
||||
constructor(agent, region, seedURL, clientEvents) {
|
||||
this.onGotSeedCap = new Subject_1.Subject();
|
||||
this.gotSeedCap = false;
|
||||
this.capabilities = {};
|
||||
this.eventQueueClient = null;
|
||||
this.agent = agent;
|
||||
this.clientEvents = clientEvents;
|
||||
this.region = region;
|
||||
const req = [];
|
||||
@@ -109,7 +110,7 @@ class Caps {
|
||||
if (this.eventQueueClient !== null) {
|
||||
this.eventQueueClient.shutdown();
|
||||
}
|
||||
this.eventQueueClient = new EventQueueClient_1.EventQueueClient(this, this.clientEvents);
|
||||
this.eventQueueClient = new EventQueueClient_1.EventQueueClient(this.agent, this, this.clientEvents);
|
||||
}
|
||||
}).catch((err) => {
|
||||
console.error('Error getting seed capability');
|
||||
|
||||
2
dist/classes/Caps.js.map
vendored
2
dist/classes/Caps.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/classes/ClientEvents.d.ts
vendored
2
dist/classes/ClientEvents.d.ts
vendored
@@ -7,6 +7,7 @@ import { GroupInviteEvent } from '../events/GroupInviteEvent';
|
||||
import { FriendRequestEvent } from '../events/FriendRequestEvent';
|
||||
import { DisconnectEvent } from '../events/DisconnectEvent';
|
||||
import { GroupChatEvent } from '../events/GroupChatEvent';
|
||||
import { GroupChatSessionJoinEvent } from '../events/GroupChatSessionJoinEvent';
|
||||
export declare class ClientEvents {
|
||||
onNearbyChat: Subject<ChatEvent>;
|
||||
onInstantMessage: Subject<InstantMessageEvent>;
|
||||
@@ -17,4 +18,5 @@ export declare class ClientEvents {
|
||||
onDisconnected: Subject<DisconnectEvent>;
|
||||
onCircuitLatency: Subject<number>;
|
||||
onGroupChat: Subject<GroupChatEvent>;
|
||||
onGroupChatSessionJoin: Subject<GroupChatSessionJoinEvent>;
|
||||
}
|
||||
|
||||
1
dist/classes/ClientEvents.js
vendored
1
dist/classes/ClientEvents.js
vendored
@@ -12,6 +12,7 @@ class ClientEvents {
|
||||
this.onDisconnected = new Subject_1.Subject();
|
||||
this.onCircuitLatency = new Subject_1.Subject();
|
||||
this.onGroupChat = new Subject_1.Subject();
|
||||
this.onGroupChatSessionJoin = new Subject_1.Subject();
|
||||
}
|
||||
}
|
||||
exports.ClientEvents = ClientEvents;
|
||||
|
||||
2
dist/classes/ClientEvents.js.map
vendored
2
dist/classes/ClientEvents.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"ClientEvents.js","sourceRoot":"","sources":["../../lib/classes/ClientEvents.ts"],"names":[],"mappings":";;AAGA,0CAAqC;AAOrC;IAAA;QAEI,iBAAY,GAAuB,IAAI,iBAAO,EAAa,CAAC;QAC5D,qBAAgB,GAAiC,IAAI,iBAAO,EAAuB,CAAC;QACpF,kBAAa,GAA8B,IAAI,iBAAO,EAAoB,CAAC;QAC3E,oBAAe,GAAgC,IAAI,iBAAO,EAAsB,CAAC;QACjF,WAAM,GAAuB,IAAI,iBAAO,EAAa,CAAC;QACtD,oBAAe,GAA2B,IAAI,iBAAO,EAAiB,CAAC;QACvE,mBAAc,GAA8B,IAAI,iBAAO,EAAmB,CAAC;QAC3E,qBAAgB,GAAoB,IAAI,iBAAO,EAAU,CAAC;QAC1D,gBAAW,GAA4B,IAAI,iBAAO,EAAkB,CAAC;IACzE,CAAC;CAAA;AAXD,oCAWC"}
|
||||
{"version":3,"file":"ClientEvents.js","sourceRoot":"","sources":["../../lib/classes/ClientEvents.ts"],"names":[],"mappings":";;AAGA,0CAAqC;AAQrC;IAAA;QAEI,iBAAY,GAAuB,IAAI,iBAAO,EAAa,CAAC;QAC5D,qBAAgB,GAAiC,IAAI,iBAAO,EAAuB,CAAC;QACpF,kBAAa,GAA8B,IAAI,iBAAO,EAAoB,CAAC;QAC3E,oBAAe,GAAgC,IAAI,iBAAO,EAAsB,CAAC;QACjF,WAAM,GAAuB,IAAI,iBAAO,EAAa,CAAC;QACtD,oBAAe,GAA2B,IAAI,iBAAO,EAAiB,CAAC;QACvE,mBAAc,GAA8B,IAAI,iBAAO,EAAmB,CAAC;QAC3E,qBAAgB,GAAoB,IAAI,iBAAO,EAAU,CAAC;QAC1D,gBAAW,GAA4B,IAAI,iBAAO,EAAkB,CAAC;QACrE,2BAAsB,GAAuC,IAAI,iBAAO,EAA6B,CAAC;IAC1G,CAAC;CAAA;AAZD,oCAYC"}
|
||||
4
dist/classes/EventQueueClient.d.ts
vendored
4
dist/classes/EventQueueClient.d.ts
vendored
@@ -2,13 +2,15 @@
|
||||
import { Caps } from './Caps';
|
||||
import * as request from 'request';
|
||||
import { ClientEvents } from './ClientEvents';
|
||||
import { Agent } from './Agent';
|
||||
export declare class EventQueueClient {
|
||||
caps: Caps;
|
||||
ack?: number;
|
||||
done: boolean;
|
||||
currentRequest: request.Request | null;
|
||||
private clientEvents;
|
||||
constructor(caps: Caps, clientEvents: ClientEvents);
|
||||
private agent;
|
||||
constructor(agent: Agent, caps: Caps, clientEvents: ClientEvents);
|
||||
shutdown(): void;
|
||||
Get(): void;
|
||||
request(url: string, data: string, contentType: string): Promise<string>;
|
||||
|
||||
22
dist/classes/EventQueueClient.js
vendored
22
dist/classes/EventQueueClient.js
vendored
@@ -8,10 +8,12 @@ const TeleportEvent_1 = require("../events/TeleportEvent");
|
||||
const TeleportEventType_1 = require("../enums/TeleportEventType");
|
||||
const GroupChatEvent_1 = require("../events/GroupChatEvent");
|
||||
const UUID_1 = require("./UUID");
|
||||
const GroupChatSessionJoinEvent_1 = require("../events/GroupChatSessionJoinEvent");
|
||||
class EventQueueClient {
|
||||
constructor(caps, clientEvents) {
|
||||
constructor(agent, caps, clientEvents) {
|
||||
this.done = false;
|
||||
this.currentRequest = null;
|
||||
this.agent = agent;
|
||||
this.clientEvents = clientEvents;
|
||||
this.caps = caps;
|
||||
this.Get();
|
||||
@@ -52,6 +54,19 @@ class EventQueueClient {
|
||||
this.clientEvents.onTeleportEvent.next(tpEvent);
|
||||
break;
|
||||
}
|
||||
case "ChatterBoxSessionStartReply":
|
||||
{
|
||||
if (event['body']) {
|
||||
const gcsje = new GroupChatSessionJoinEvent_1.GroupChatSessionJoinEvent();
|
||||
gcsje.sessionID = new UUID_1.UUID(event['body']['session_id'].toString());
|
||||
gcsje.success = event['body']['success'];
|
||||
if (gcsje.success) {
|
||||
this.agent.addChatSession(gcsje.sessionID);
|
||||
}
|
||||
this.clientEvents.onGroupChatSessionJoin.next(gcsje);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'ChatterBoxInvitation':
|
||||
{
|
||||
if (event['body'] && event['body']['instantmessage'] && event['body']['instantmessage']['message_params'] && event['body']['instantmessage']['message_params']['id']) {
|
||||
@@ -67,6 +82,11 @@ class EventQueueClient {
|
||||
groupChatEvent.groupID = new UUID_1.UUID(messageParams['id'].toString());
|
||||
groupChatEvent.message = messageParams['message'];
|
||||
this.caps.capsRequestXML('ChatSessionRequest', requestedFolders).then((result) => {
|
||||
this.agent.addChatSession(groupChatEvent.groupID);
|
||||
const gcsje = new GroupChatSessionJoinEvent_1.GroupChatSessionJoinEvent();
|
||||
gcsje.sessionID = groupChatEvent.groupID;
|
||||
gcsje.success = true;
|
||||
this.clientEvents.onGroupChatSessionJoin.next(gcsje);
|
||||
this.clientEvents.onGroupChat.next(groupChatEvent);
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
|
||||
2
dist/classes/EventQueueClient.js.map
vendored
2
dist/classes/EventQueueClient.js.map
vendored
File diff suppressed because one or more lines are too long
1
dist/classes/Region.d.ts
vendored
1
dist/classes/Region.d.ts
vendored
@@ -14,6 +14,7 @@ export declare class Region {
|
||||
comms: Comms;
|
||||
clientEvents: ClientEvents;
|
||||
options: BotOptionFlags;
|
||||
agent: Agent;
|
||||
constructor(agent: Agent, clientEvents: ClientEvents, options: BotOptionFlags);
|
||||
activateCaps(seedURL: string): void;
|
||||
shutdown(): void;
|
||||
|
||||
3
dist/classes/Region.js
vendored
3
dist/classes/Region.js
vendored
@@ -8,6 +8,7 @@ const BotOptionFlags_1 = require("../enums/BotOptionFlags");
|
||||
const ObjectStoreLite_1 = require("./ObjectStoreLite");
|
||||
class Region {
|
||||
constructor(agent, clientEvents, options) {
|
||||
this.agent = agent;
|
||||
this.options = options;
|
||||
this.clientEvents = clientEvents;
|
||||
this.circuit = new Circuit_1.Circuit(clientEvents);
|
||||
@@ -20,7 +21,7 @@ class Region {
|
||||
this.comms = new Comms_1.Comms(this.circuit, agent, clientEvents);
|
||||
}
|
||||
activateCaps(seedURL) {
|
||||
this.caps = new Caps_1.Caps(this, seedURL, this.clientEvents);
|
||||
this.caps = new Caps_1.Caps(this.agent, this, seedURL, this.clientEvents);
|
||||
}
|
||||
shutdown() {
|
||||
this.comms.shutdown();
|
||||
|
||||
2
dist/classes/Region.js.map
vendored
2
dist/classes/Region.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"Region.js","sourceRoot":"","sources":["../../lib/classes/Region.ts"],"names":[],"mappings":";;AAAA,uCAAkC;AAElC,iCAA4B;AAC5B,mCAA8B;AAG9B,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
|
||||
console.error('Can\'t accept UUIDs of type ' + typeof buf);
|
||||
console.trace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
dist/classes/UUID.js.map
vendored
2
dist/classes/UUID.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"UUID.js","sourceRoot":"","sources":["../../lib/classes/UUID.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AACvC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7B;IAcI,YAAY,GAAqB,EAAE,GAAY;QAZvC,UAAK,GAAG,sCAAsC,CAAC;QAqDhD,aAAQ,GAAG,GAAW,EAAE;YAE3B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC,CAAC;QA1CE,EAAE,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC,CACtB,CAAC;YACG,EAAE,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAC5B,CAAC;gBACG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACtB,CAAC;YACD,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC,CAC3B,CAAC;gBACG,MAAM,OAAO,GAAW,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;gBACjD,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAC1C,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG;sBACnC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG;sBAC5B,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG;sBAC7B,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG;sBAC7B,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,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AC,CAAC;QACtJ,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CACJ;AAjED,oBAiEC"}
|
||||
@@ -15,6 +15,7 @@ export declare class CommunicationsCommands extends CommandsBase {
|
||||
acceptGroupInvite(event: GroupInviteEvent): Promise<void>;
|
||||
rejectGroupInvite(event: GroupInviteEvent): Promise<void>;
|
||||
typeInstantMessage(to: UUID | string, message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>;
|
||||
startChatSession(sessionID: UUID | string): Promise<void>;
|
||||
sendGroupMessage(groupID: UUID | string, message: string): Promise<void>;
|
||||
typeLocalMessage(message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>;
|
||||
}
|
||||
|
||||
114
dist/classes/commands/CommunicationsCommands.js
vendored
114
dist/classes/commands/CommunicationsCommands.js
vendored
@@ -226,7 +226,6 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
|
||||
this.startTypingIM(to).then(() => {
|
||||
typeTimer = setInterval(() => {
|
||||
this.startTypingIM(to).catch(() => {
|
||||
// ignore
|
||||
});
|
||||
}, 5000);
|
||||
if (charactersPerSecond === undefined) {
|
||||
@@ -258,36 +257,91 @@ class CommunicationsCommands extends CommandsBase_1.CommandsBase {
|
||||
}, thinkingTime);
|
||||
});
|
||||
}
|
||||
startChatSession(sessionID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof sessionID === 'string') {
|
||||
sessionID = new UUID_1.UUID(sessionID);
|
||||
}
|
||||
if (this.agent.hasChatSession(sessionID)) {
|
||||
resolve();
|
||||
}
|
||||
else {
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: sessionID,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID_1.UUID.zero(),
|
||||
Position: Vector3_1.Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog_1.InstantMessageDialog.SessionGroupStart,
|
||||
ID: sessionID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
|
||||
Message: Utils_1.Utils.StringToBuffer(''),
|
||||
BinaryBucket: Utils_1.Utils.StringToBuffer('')
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const waitForJoin = this.currentRegion.clientEvents.onGroupChatSessionJoin.subscribe((event) => {
|
||||
if (event.sessionID.toString() === sessionID.toString()) {
|
||||
if (event.success) {
|
||||
waitForJoin.unsubscribe();
|
||||
resolve();
|
||||
}
|
||||
else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
});
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
|
||||
}
|
||||
});
|
||||
}
|
||||
sendGroupMessage(groupID, message) {
|
||||
if (typeof groupID === 'string') {
|
||||
groupID = new UUID_1.UUID(groupID);
|
||||
}
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: groupID,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID_1.UUID.zero(),
|
||||
Position: Vector3_1.Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog_1.InstantMessageDialog.SessionSend,
|
||||
ID: groupID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
|
||||
Message: Utils_1.Utils.StringToBuffer(message),
|
||||
BinaryBucket: Utils_1.Utils.StringToBuffer('')
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
return new Promise((resolve, reject) => {
|
||||
this.startChatSession(groupID).then(() => {
|
||||
console.log('Session joined');
|
||||
if (typeof groupID === 'string') {
|
||||
groupID = new UUID_1.UUID(groupID);
|
||||
}
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im = new ImprovedInstantMessage_1.ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: groupID,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID_1.UUID.zero(),
|
||||
Position: Vector3_1.Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog_1.InstantMessageDialog.SessionSend,
|
||||
ID: groupID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils_1.Utils.StringToBuffer(agentName),
|
||||
Message: Utils_1.Utils.StringToBuffer(message),
|
||||
BinaryBucket: Utils_1.Utils.StringToBuffer('')
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags_1.PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
typeLocalMessage(message, thinkingTime, charactersPerSecond) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,6 +2,7 @@ const nmv = require('../dist/index');
|
||||
const loginParameters = new nmv.LoginParameters();
|
||||
|
||||
const parameters = require('./loginParameters.json');
|
||||
const uuid = require('uuid');
|
||||
|
||||
loginParameters.firstName = parameters.firstName;
|
||||
loginParameters.lastName = parameters.lastName;
|
||||
@@ -21,6 +22,8 @@ let isConnected = false;
|
||||
|
||||
const master = 'd1cd5b71-6209-4595-9bf0-771bf689ce00';
|
||||
|
||||
let loginResponse = null;
|
||||
|
||||
bot.clientEvents.onLure.subscribe((lureEvent) =>
|
||||
{
|
||||
bot.clientCommands.grid.getRegionMapInfo(lureEvent.gridX, lureEvent.gridY).then((regionInfo) =>
|
||||
@@ -62,13 +65,35 @@ bot.clientEvents.onDisconnected.subscribe((DisconnectEvent) =>
|
||||
}
|
||||
});
|
||||
|
||||
let pings = {};
|
||||
|
||||
bot.clientEvents.onGroupChat.subscribe((GroupChatEvent) =>
|
||||
{
|
||||
console.log("Group chat: " + GroupChatEvent.fromName + ': ' + GroupChatEvent.message);
|
||||
if (GroupChatEvent.message === 'marco')
|
||||
if (GroupChatEvent.message === '!ping')
|
||||
{
|
||||
console.log("Sending PONG");
|
||||
bot.clientCommands.comms.sendGroupMessage(GroupChatEvent.groupID, 'polo');
|
||||
let ping = uuid.v4();
|
||||
pings[ping] = Math.floor(new Date().getTime());
|
||||
bot.clientCommands.comms.sendGroupMessage(GroupChatEvent.groupID, 'ping '+ping);
|
||||
}
|
||||
else if (GroupChatEvent.from.toString() === loginResponse.agent.agentID.toString())
|
||||
{
|
||||
if (GroupChatEvent.message.substr(0, 5) === 'ping ')
|
||||
{
|
||||
const pingID = GroupChatEvent.message.substr(5);
|
||||
if (pings[pingID])
|
||||
{
|
||||
console.log("found ping");
|
||||
const time = (new Date().getTime()) - pings[pingID];
|
||||
delete pings[pingID];
|
||||
bot.clientCommands.comms.sendGroupMessage(GroupChatEvent.groupID, 'Chat lag: ' + time + 'ms');
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("ping not found |"+pingID+"|");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -103,6 +128,7 @@ function connect()
|
||||
console.log("Logging in..");
|
||||
bot.login().then((response) =>
|
||||
{
|
||||
loginResponse = response;
|
||||
console.log("Login complete");
|
||||
|
||||
//Establish circuit with region
|
||||
|
||||
@@ -36,6 +36,7 @@ export class Agent
|
||||
regionAccess: string;
|
||||
agentAccess: string;
|
||||
currentRegion: Region;
|
||||
chatSessions: string[] = [];
|
||||
controlFlags: ControlFlags = 0;
|
||||
openID: {
|
||||
'token'?: string,
|
||||
@@ -80,6 +81,25 @@ export class Agent
|
||||
this.clientEvents = clientEvents;
|
||||
}
|
||||
|
||||
addChatSession(uuid: UUID)
|
||||
{
|
||||
const str = uuid.toString();
|
||||
if (this.chatSessions.indexOf(str) === -1)
|
||||
{
|
||||
this.chatSessions.push(str);
|
||||
}
|
||||
}
|
||||
|
||||
hasChatSession(uuid: UUID): boolean
|
||||
{
|
||||
const str = uuid.toString();
|
||||
if (this.chatSessions.indexOf(str) === -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
setCurrentRegion(region: Region)
|
||||
{
|
||||
this.currentRegion = region;
|
||||
|
||||
@@ -7,6 +7,7 @@ import {EventQueueClient} from './EventQueueClient';
|
||||
import {UUID} from './UUID';
|
||||
import {HTTPAssets} from '../enums/HTTPAssets';
|
||||
import {ClientEvents} from "./ClientEvents";
|
||||
import {Agent} from './Agent';
|
||||
|
||||
export class Caps
|
||||
{
|
||||
@@ -15,10 +16,12 @@ export class Caps
|
||||
private gotSeedCap: boolean = false;
|
||||
private capabilities: { [key: string]: string } = {};
|
||||
private clientEvents: ClientEvents;
|
||||
private agent: Agent;
|
||||
eventQueueClient: EventQueueClient | null = null;
|
||||
|
||||
constructor(region: Region, seedURL: string, clientEvents: ClientEvents)
|
||||
constructor(agent: Agent, region: Region, seedURL: string, clientEvents: ClientEvents)
|
||||
{
|
||||
this.agent = agent;
|
||||
this.clientEvents = clientEvents;
|
||||
this.region = region;
|
||||
const req: string[] = [];
|
||||
@@ -122,7 +125,7 @@ export class Caps
|
||||
{
|
||||
this.eventQueueClient.shutdown();
|
||||
}
|
||||
this.eventQueueClient = new EventQueueClient(this, this.clientEvents);
|
||||
this.eventQueueClient = new EventQueueClient(this.agent, this, this.clientEvents);
|
||||
}
|
||||
}).catch((err) =>
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ import {GroupInviteEvent} from '../events/GroupInviteEvent';
|
||||
import {FriendRequestEvent} from '../events/FriendRequestEvent';
|
||||
import {DisconnectEvent} from '../events/DisconnectEvent';
|
||||
import {GroupChatEvent} from '../events/GroupChatEvent';
|
||||
import {GroupChatSessionJoinEvent} from '../events/GroupChatSessionJoinEvent';
|
||||
|
||||
export class ClientEvents
|
||||
{
|
||||
@@ -19,4 +20,5 @@ export class ClientEvents
|
||||
onDisconnected: Subject<DisconnectEvent> = new Subject<DisconnectEvent>();
|
||||
onCircuitLatency: Subject<number> = new Subject<number>();
|
||||
onGroupChat: Subject<GroupChatEvent> = new Subject<GroupChatEvent>();
|
||||
onGroupChatSessionJoin: Subject<GroupChatSessionJoinEvent> = new Subject<GroupChatSessionJoinEvent>();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import {TeleportEventType} from '../enums/TeleportEventType';
|
||||
import {GroupChatEvent} from '../events/GroupChatEvent';
|
||||
import {Utils} from './Utils';
|
||||
import {UUID} from './UUID';
|
||||
import {Agent} from './Agent';
|
||||
import {GroupChatSessionJoinEvent} from '../events/GroupChatSessionJoinEvent';
|
||||
|
||||
export class EventQueueClient
|
||||
{
|
||||
@@ -17,9 +19,11 @@ export class EventQueueClient
|
||||
done = false;
|
||||
currentRequest: request.Request | null = null;
|
||||
private clientEvents: ClientEvents;
|
||||
private agent: Agent;
|
||||
|
||||
constructor(caps: Caps, clientEvents: ClientEvents)
|
||||
constructor(agent: Agent, caps: Caps, clientEvents: ClientEvents)
|
||||
{
|
||||
this.agent = agent;
|
||||
this.clientEvents = clientEvents;
|
||||
this.caps = caps;
|
||||
this.Get();
|
||||
@@ -255,6 +259,21 @@ export class EventQueueClient
|
||||
this.clientEvents.onTeleportEvent.next(tpEvent);
|
||||
break;
|
||||
}
|
||||
case "ChatterBoxSessionStartReply":
|
||||
{
|
||||
if (event['body'])
|
||||
{
|
||||
const gcsje = new GroupChatSessionJoinEvent();
|
||||
gcsje.sessionID = new UUID(event['body']['session_id'].toString());
|
||||
gcsje.success = event['body']['success'];
|
||||
if (gcsje.success)
|
||||
{
|
||||
this.agent.addChatSession(gcsje.sessionID);
|
||||
}
|
||||
this.clientEvents.onGroupChatSessionJoin.next(gcsje);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'ChatterBoxInvitation':
|
||||
{
|
||||
if (event['body'] && event['body']['instantmessage'] && event['body']['instantmessage']['message_params'] && event['body']['instantmessage']['message_params']['id'])
|
||||
@@ -275,6 +294,12 @@ export class EventQueueClient
|
||||
|
||||
this.caps.capsRequestXML('ChatSessionRequest', requestedFolders).then((result: any) =>
|
||||
{
|
||||
this.agent.addChatSession(groupChatEvent.groupID);
|
||||
|
||||
const gcsje = new GroupChatSessionJoinEvent();
|
||||
gcsje.sessionID = groupChatEvent.groupID;
|
||||
gcsje.success = true;
|
||||
this.clientEvents.onGroupChatSessionJoin.next(gcsje);
|
||||
this.clientEvents.onGroupChat.next(groupChatEvent);
|
||||
}).catch((err) =>
|
||||
{
|
||||
|
||||
@@ -18,9 +18,11 @@ export class Region
|
||||
comms: Comms;
|
||||
clientEvents: ClientEvents;
|
||||
options: BotOptionFlags;
|
||||
agent: Agent;
|
||||
|
||||
constructor(agent: Agent, clientEvents: ClientEvents, options: BotOptionFlags)
|
||||
{
|
||||
this.agent = agent;
|
||||
this.options = options;
|
||||
this.clientEvents = clientEvents;
|
||||
this.circuit = new Circuit(clientEvents);
|
||||
@@ -36,7 +38,7 @@ export class Region
|
||||
}
|
||||
activateCaps(seedURL: string)
|
||||
{
|
||||
this.caps = new Caps(this, seedURL, this.clientEvents);
|
||||
this.caps = new Caps(this.agent, this, seedURL, this.clientEvents);
|
||||
}
|
||||
shutdown()
|
||||
{
|
||||
|
||||
@@ -36,7 +36,6 @@ export class UUID
|
||||
else
|
||||
{
|
||||
console.error('Can\'t accept UUIDs of type ' + typeof buf);
|
||||
console.trace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import {ChatType} from '../../enums/ChatType';
|
||||
import {InstantMessageDialog} from '../../enums/InstantMessageDialog';
|
||||
import Timer = NodeJS.Timer;
|
||||
import {GroupInviteEvent} from '../../events/GroupInviteEvent';
|
||||
import * as LLSD from 'llsd';
|
||||
import {GroupChatSessionJoinEvent} from '../../events/GroupChatSessionJoinEvent';
|
||||
|
||||
export class CommunicationsCommands extends CommandsBase
|
||||
{
|
||||
@@ -305,38 +307,106 @@ export class CommunicationsCommands extends CommandsBase
|
||||
});
|
||||
}
|
||||
|
||||
startChatSession(sessionID: UUID | string): Promise<void>
|
||||
{
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
{
|
||||
if (typeof sessionID === 'string')
|
||||
{
|
||||
sessionID = new UUID(sessionID);
|
||||
}
|
||||
if (this.agent.hasChatSession(sessionID))
|
||||
{
|
||||
resolve();
|
||||
}
|
||||
else
|
||||
{
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: sessionID,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.SessionGroupStart,
|
||||
ID: sessionID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(''),
|
||||
BinaryBucket: Utils.StringToBuffer('')
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const waitForJoin = this.currentRegion.clientEvents.onGroupChatSessionJoin.subscribe((event: GroupChatSessionJoinEvent) =>
|
||||
{
|
||||
if (event.sessionID.toString() === sessionID.toString())
|
||||
{
|
||||
if (event.success)
|
||||
{
|
||||
waitForJoin.unsubscribe();
|
||||
resolve();
|
||||
}
|
||||
else
|
||||
{
|
||||
reject();
|
||||
}
|
||||
}
|
||||
});
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
sendGroupMessage(groupID: UUID | string, message: string): Promise<void>
|
||||
{
|
||||
if (typeof groupID === 'string')
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
{
|
||||
groupID = new UUID(groupID);
|
||||
}
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: groupID,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.SessionSend,
|
||||
ID: groupID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(message),
|
||||
BinaryBucket: Utils.StringToBuffer('')
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
this.startChatSession(groupID).then(() =>
|
||||
{
|
||||
console.log('Session joined');
|
||||
if (typeof groupID === 'string')
|
||||
{
|
||||
groupID = new UUID(groupID);
|
||||
}
|
||||
const circuit = this.circuit;
|
||||
const agentName = this.agent.firstName + ' ' + this.agent.lastName;
|
||||
const im: ImprovedInstantMessageMessage = new ImprovedInstantMessageMessage();
|
||||
im.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: circuit.sessionID
|
||||
};
|
||||
im.MessageBlock = {
|
||||
FromGroup: false,
|
||||
ToAgentID: groupID,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.SessionSend,
|
||||
ID: groupID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(message),
|
||||
BinaryBucket: Utils.StringToBuffer('')
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}).catch((err) =>
|
||||
{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
typeLocalMessage(message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>
|
||||
|
||||
7
lib/events/GroupChatSessionJoinEvent.ts
Normal file
7
lib/events/GroupChatSessionJoinEvent.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import {UUID} from '../classes/UUID';
|
||||
|
||||
export class GroupChatSessionJoinEvent
|
||||
{
|
||||
sessionID: UUID;
|
||||
success: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user