From 0b4960eb4f2f1105d530a01eb78dbead2953e2c5 Mon Sep 17 00:00:00 2001 From: hintswen Date: Tue, 6 Nov 2018 16:59:37 +1100 Subject: [PATCH] Fixed issue sending message twice, simplified paramaters --- lib/classes/commands/GroupCommands.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/classes/commands/GroupCommands.ts b/lib/classes/commands/GroupCommands.ts index 6002653..8962e82 100644 --- a/lib/classes/commands/GroupCommands.ts +++ b/lib/classes/commands/GroupCommands.ts @@ -293,9 +293,7 @@ export class GroupCommands extends CommandsBase }); } - async ejectFromGroupBulk(groupID: UUID | string, sendTo: { - ejecteeID: UUID | string - }[]): Promise + async ejectFromGroupBulk(groupID: UUID | string, sendTo: UUID[] | string[]): Promise { if (typeof groupID === 'string') { @@ -313,18 +311,16 @@ export class GroupCommands extends CommandsBase }; msg.EjectData = []; - sendTo.forEach((to) => + for (let ejecteeID of sendTo) { - if (typeof to.ejecteeID === 'string') + if (typeof ejecteeID === 'string') { - to.ejecteeID = new UUID(to.ejecteeID); + ejecteeID = new UUID(ejecteeID); } msg.EjectData.push({ - EjecteeID: to.ejecteeID + EjecteeID: ejecteeID }); - }); - - this.circuit.sendMessage(msg, PacketFlags.Reliable); + }; const sequenceNo = this.circuit.sendMessage(msg, PacketFlags.Reliable); return await this.circuit.waitForAck(sequenceNo, 10000); @@ -332,9 +328,13 @@ export class GroupCommands extends CommandsBase async ejectFromGroup(groupID: UUID | string, ejecteeID: UUID | string): Promise { - const sendTo = [{ - ejecteeID: ejecteeID - }]; + if (typeof ejecteeID === 'string') + { + ejecteeID = new UUID(ejecteeID); + } + + const sendTo: UUID[] = [ejecteeID]; + return await this.ejectFromGroupBulk(groupID, sendTo); } }