Class: Smpp::Pdu::SubmitMultiResponse

Inherits:
Base
  • Object
show all
Defined in:
lib/smpp/pdu/submit_multi_response.rb

Overview

Recieving response for an MT message sent to multiple addresses Author: Abhishek Parolkar, (abhishekparolkar.com)

Defined Under Namespace

Classes: UnsuccessfulSme

Constant Summary

Constants inherited from Base

Base::BIND_RECEIVER, Base::BIND_RECEIVER_RESP, Base::BIND_TRANSCEIVER, Base::BIND_TRANSCEIVER_RESP, Base::BIND_TRANSMITTER, Base::BIND_TRANSMITTER_RESP, Base::CANCEL_SM, Base::CANCEL_SM_RESP, Base::DELIVER_SM, Base::DELIVER_SM_RESP, Base::ENQUIRE_LINK, Base::ENQUIRE_LINK_RESP, Base::ESME_RALYBND, Base::ESME_RBINDFAIL, Base::ESME_RCANCELFAIL, Base::ESME_RCNTSUBDL, Base::ESME_RINVBNDSTS, Base::ESME_RINVCMDID, Base::ESME_RINVCMDLEN, Base::ESME_RINVDESTFLAG, Base::ESME_RINVDLNAME, Base::ESME_RINVDSTADR, Base::ESME_RINVDSTNPI, Base::ESME_RINVDSTTON, Base::ESME_RINVESMCLASS, Base::ESME_RINVMSGID, Base::ESME_RINVMSGLEN, Base::ESME_RINVNUMDESTS, Base::ESME_RINVNUMMSGS, Base::ESME_RINVPASWD, Base::ESME_RINVPRTFLG, Base::ESME_RINVREGDLVFLG, Base::ESME_RINVREPFLAG, Base::ESME_RINVSERTYP, Base::ESME_RINVSRCADR, Base::ESME_RINVSRCNPI, Base::ESME_RINVSRCTON, Base::ESME_RINVSUBREP, Base::ESME_RINVSYSID, Base::ESME_RINVSYSTYP, Base::ESME_RMSGQFUL, Base::ESME_ROK, Base::ESME_RREPLACEFAIL, Base::ESME_RSUBMITFAIL, Base::ESME_RSYSERR, Base::ESME_RTHROTTLED, Base::ESME_RX_T_APPN, Base::GENERIC_NACK, Base::OPTIONAL_MESSAGE_STATE, Base::OPTIONAL_RECEIPTED_MESSAGE_ID, Base::PROTOCOL_VERSION, Base::QUERY_SM, Base::QUERY_SM_RESP, Base::REPLACE_SM, Base::REPLACE_SM_RESP, Base::SEQUENCE_MAX, Base::SUBMIT_MULTI, Base::SUBMIT_MULTI_RESP, Base::SUBMIT_SM, Base::SUBMIT_SM_RESP, Base::UNBIND, Base::UNBIND_RESP

Instance Attribute Summary collapse

Attributes inherited from Base

#body, #command_id, #command_status, #data, #sequence_number

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

create, fixed_int, #fixed_int, handles_cmd, #logger, next_sequence_number, #next_sequence_number, #optional_parameters_to_buffer, optional_parameters_to_buffer, parse_optional_parameters, #to_human

Constructor Details

#initialize(seq, status, message_id, unsuccess_smes = []) ⇒ SubmitMultiResponse

Returns a new instance of SubmitMultiResponse.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/smpp/pdu/submit_multi_response.rb', line 12

def initialize(seq, status, message_id, unsuccess_smes = [])
  @unsuccess_smes = unsuccess_smes
  seq ||= next_sequence_number

  packed_smes = ""
  unsuccess_smes.each do |sme|
    packed_smes << [
      sme.dest_addr_ton, 
      sme.dest_addr_npi, 
      sme.destination_addr, 
      sme.error_status_code
    ].pack("CCZ*N")
  end
  body = [message_id, unsuccess_smes.size, packed_smes].pack("Z*Ca*")

  super(SUBMIT_MULTI_RESP, status, seq, body)
  @message_id = message_id
end

Instance Attribute Details

#message_idObject

Returns the value of attribute message_id.



10
11
12
# File 'lib/smpp/pdu/submit_multi_response.rb', line 10

def message_id
  @message_id
end

#unsuccess_smesObject

Returns the value of attribute unsuccess_smes.



10
11
12
# File 'lib/smpp/pdu/submit_multi_response.rb', line 10

def unsuccess_smes
  @unsuccess_smes
end

Class Method Details

.from_wire_data(seq, status, body) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/smpp/pdu/submit_multi_response.rb', line 31

def self.from_wire_data(seq, status, body)
  message_id, no_unsuccess, rest = body.unpack("Z*Ca*")
  unsuccess_smes = []

  no_unsuccess.times do |i|
    #unpack the next sme
    dest_addr_ton, dest_addr_npi, destination_addr, error_status_code =
      rest.unpack("CCZ*N")
    #remove the SME from rest 
    rest.slice!(0,7 + destination_addr.length)
    unsuccess_smes << UnsuccessfulSme.new(dest_addr_ton, dest_addr_npi, destination_addr, error_status_code)
  end
  
  new(seq, status, message_id, unsuccess_smes)
end