package mtproto

import (
	

	
	

	
)

func ( *Conn) ( context.Context) error {
	 := .log.Named("ack")

	var  []int64
	 := func() {
		defer func() {  = [:0] }()

		if  := .writeServiceMessage(, &mt.MsgsAck{MsgIDs: });  != nil {
			.log.Error("Failed to ACK", zap.Error())
			return
		}

		.Debug("Ack", zap.Int64s("msg_ids", ))
	}

	 := .clock.Ticker(.ackInterval)
	defer .Stop()

	for {
		select {
		case <-.Done():
			return errors.Wrap(.Err(), "acl")
		case <-.C():
			if len() > 0 {
				()
			}
		case  := <-.ackSendChan:
			 = append(, )
			if len() >= .ackBatchSize {
				()
				.Reset(.ackInterval)
			}
		}
	}
}