Name2key, Group chat, Group invite / group invite accept / group invite reject
This commit is contained in:
@@ -8,6 +8,7 @@ import {ChatFromViewerMessage} from '../messages/ChatFromViewer';
|
||||
import {ChatType} from '../../enums/ChatType';
|
||||
import {InstantMessageDialog} from '../../enums/InstantMessageDialog';
|
||||
import Timer = NodeJS.Timer;
|
||||
import {GroupInviteEvent} from '../../events/GroupInviteEvent';
|
||||
|
||||
export class CommunicationsCommands extends CommandsBase
|
||||
{
|
||||
@@ -33,7 +34,7 @@ export class CommunicationsCommands extends CommandsBase
|
||||
Offline: 1,
|
||||
Dialog: 0,
|
||||
ID: UUID.zero(),
|
||||
Timestamp: 0,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(message),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
@@ -134,7 +135,7 @@ export class CommunicationsCommands extends CommandsBase
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.StartTyping,
|
||||
ID: UUID.zero(),
|
||||
Timestamp: 0,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
@@ -168,7 +169,67 @@ export class CommunicationsCommands extends CommandsBase
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.StopTyping,
|
||||
ID: UUID.zero(),
|
||||
Timestamp: 0,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
|
||||
acceptGroupInvite(event: GroupInviteEvent): Promise<void>
|
||||
{
|
||||
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: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.GroupInvitationAccept,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
};
|
||||
im.EstateBlock = {
|
||||
EstateID: 0
|
||||
};
|
||||
const sequenceNo = circuit.sendMessage(im, PacketFlags.Reliable);
|
||||
return circuit.waitForAck(sequenceNo, 10000);
|
||||
}
|
||||
|
||||
rejectGroupInvite(event: GroupInviteEvent): Promise<void>
|
||||
{
|
||||
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: event.from,
|
||||
ParentEstateID: 0,
|
||||
RegionID: UUID.zero(),
|
||||
Position: Vector3.getZero(),
|
||||
Offline: 0,
|
||||
Dialog: InstantMessageDialog.GroupInvitationDecline,
|
||||
ID: event.inviteID,
|
||||
Timestamp: Math.floor(new Date().getTime() / 1000),
|
||||
FromAgentName: Utils.StringToBuffer(agentName),
|
||||
Message: Utils.StringToBuffer(''),
|
||||
BinaryBucket: Buffer.allocUnsafe(0)
|
||||
@@ -244,6 +305,36 @@ export class CommunicationsCommands extends CommandsBase
|
||||
});
|
||||
}
|
||||
|
||||
sendGroupMessage(groupID: UUID, message: string): Promise<void>
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
typeLocalMessage(message: string, thinkingTime?: number, charactersPerSecond?: number): Promise<void>
|
||||
{
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
|
||||
@@ -13,6 +13,8 @@ import {PacketFlags} from '../../enums/PacketFlags';
|
||||
import {GridItemType} from '../../enums/GridItemType';
|
||||
import {RegionIDAndHandleReplyMessage} from '../messages/RegionIDAndHandleReply';
|
||||
import {CommandsBase} from './CommandsBase';
|
||||
import {AvatarPickerRequestMessage} from '../messages/AvatarPickerRequest';
|
||||
import {AvatarPickerReplyMessage} from '../messages/AvatarPickerReply';
|
||||
export class GridCommands extends CommandsBase
|
||||
{
|
||||
getRegionHandle(regionID: UUID): Promise<Long>
|
||||
@@ -138,4 +140,70 @@ export class GridCommands extends CommandsBase
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
name2Key(name: string): Promise<UUID>
|
||||
{
|
||||
const check = name.split('.');
|
||||
if (check.length > 1)
|
||||
{
|
||||
name = check.join(' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
name += ' resident';
|
||||
}
|
||||
name = name.toLowerCase();
|
||||
|
||||
const queryID = UUID.random();
|
||||
return new Promise<UUID>((resolve, reject) =>
|
||||
{
|
||||
const aprm = new AvatarPickerRequestMessage();
|
||||
aprm.AgentData = {
|
||||
AgentID: this.agent.agentID,
|
||||
SessionID: this.circuit.sessionID,
|
||||
QueryID: queryID
|
||||
};
|
||||
aprm.Data = {
|
||||
Name: Utils.StringToBuffer(name)
|
||||
};
|
||||
|
||||
this.circuit.sendMessage(aprm, PacketFlags.Reliable);
|
||||
this.circuit.waitForMessage(Message.AvatarPickerReply, 10000, (packet: Packet): boolean =>
|
||||
{
|
||||
const apr = packet.message as AvatarPickerReplyMessage;
|
||||
if (apr.AgentData.QueryID.toString() === queryID.toString())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}).then((packet: Packet) =>
|
||||
{
|
||||
let found: UUID | null = null;
|
||||
const apr = packet.message as AvatarPickerReplyMessage;
|
||||
apr.Data.forEach((dataBlock) =>
|
||||
{
|
||||
const resultName = (Utils.BufferToStringSimple(dataBlock.FirstName) + ' ' + Utils.BufferToStringSimple(dataBlock.LastName)).toLowerCase();
|
||||
if (resultName === name)
|
||||
{
|
||||
found = dataBlock.AvatarID;
|
||||
}
|
||||
});
|
||||
|
||||
if (found !== null)
|
||||
{
|
||||
resolve(found);
|
||||
}
|
||||
else
|
||||
{
|
||||
reject('Name not found')
|
||||
}
|
||||
}).catch((err) =>
|
||||
{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user