acknowledge method
Acknowledges a message
Implementation
List<PendingAck> acknowledge(String ackId) {
final ack = _pendingAcks.remove(ackId);
if (ack == null) {
throw StompAckException('No pending acknowledgment found', ackId);
}
final acknowledged = <PendingAck>[ack];
// For client mode, acknowledge all previous messages in the subscription
if (ack.ackMode == StompAckMode.client) {
final subscriptionAcks = _subscriptionAcks[ack.subscriptionId];
if (subscriptionAcks != null) {
final ackIndex = subscriptionAcks.indexOf(ack);
if (ackIndex != -1) {
// Acknowledge all messages up to and including this one
for (int i = 0; i <= ackIndex; i++) {
final pendingAck = subscriptionAcks[i];
if (pendingAck.ackId != null) {
_pendingAcks.remove(pendingAck.ackId!);
if (pendingAck != ack) {
acknowledged.add(pendingAck);
}
}
}
subscriptionAcks.removeRange(0, ackIndex + 1);
}
}
} else {
// For client-individual mode, only acknowledge this message
final subscriptionAcks = _subscriptionAcks[ack.subscriptionId];
subscriptionAcks?.remove(ack);
}
return acknowledged;
}