Skip to content

Commit 183ad04

Browse files
authored
Merge pull request #57 from temoto/skip-auto-respond
receiver: option to disable auto respond to DeliverSM
2 parents 2e4ae04 + 3295f45 commit 183ad04

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

smpp/receiver.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Receiver struct {
2828
MergeCleanupInterval time.Duration // How often to cleanup expired message parts
2929
TLS *tls.Config
3030
Handler HandlerFunc
31+
SkipAutoRespondIDs []pdu.ID
3132

3233
chanClose chan struct{}
3334

@@ -134,6 +135,15 @@ func (r *Receiver) bindFunc(c Conn) error {
134135
return nil
135136
}
136137

138+
func idInList(id pdu.ID, list []pdu.ID) bool {
139+
for _, x := range list {
140+
if x == id {
141+
return true
142+
}
143+
}
144+
return false
145+
}
146+
137147
func (r *Receiver) handlePDU() {
138148
var (
139149
ok bool
@@ -143,6 +153,7 @@ func (r *Receiver) handlePDU() {
143153
mh *MergeHolder
144154
orderedBodies []*bytes.Buffer
145155
)
156+
autoRespondDeliver := !idInList(pdu.DeliverSMID, r.SkipAutoRespondIDs)
146157

147158
loop:
148159
for {
@@ -151,7 +162,7 @@ loop:
151162
break
152163
}
153164

154-
if p.Header().ID == pdu.DeliverSMID { // Send DeliverSMResp
165+
if p.Header().ID == pdu.DeliverSMID && autoRespondDeliver { // Send DeliverSMResp
155166
pResp := pdu.NewDeliverSMRespSeq(p.Header().Seq)
156167
r.cl.Write(pResp)
157168
}

0 commit comments

Comments
 (0)