Class: Majoron::AntHill::SMPP::SMPPDeliverSMResp

Inherits:
SMPPResp show all
Defined in:
lib/pdu/smpp_deliver_sm_resp.rb

Instance Attribute Summary collapse

Attributes inherited from SMPPPDU

#header

Instance Method Summary collapse

Methods inherited from SMPPResp

#init

Methods inherited from SMPPPDU

#command_id, #command_length, #command_status, #command_status=, #sequence_number, #sequence_number=

Constructor Details

#initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil) ⇒ SMPPDeliverSMResp

Constructor.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 24

def initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil)
	super(CommandId::CM_DELIVER_SM_RESP, command_status, sequence_number)
  
	# Mandatory fields
	@message_id = ""
  
	# Optional fields
	@additional_status_info_text = nil
	@delivery_failure_reason = nil
	@network_error_code = nil
  
	# Optional fields length
	@additional_status_info_text_len = SMPPTLVLen::ZERO_LEN
	@delivery_failure_reason_len = SMPPTLVLen::BYTE_LEN
	@network_error_code_len = SMPPTLVLen::BYTE_LEN + SMPPTLVLen::WORD_LEN
end

Instance Attribute Details

#additional_status_info_textObject

Optional fields



126
127
128
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 126

def additional_status_info_text
  @additional_status_info_text
end

#additional_status_info_text_lenObject

Optional fields length



131
132
133
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 131

def additional_status_info_text_len
  @additional_status_info_text_len
end

#delivery_failure_reasonObject

Returns the value of attribute delivery_failure_reason.



127
128
129
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 127

def delivery_failure_reason
  @delivery_failure_reason
end

#delivery_failure_reason_lenObject

Returns the value of attribute delivery_failure_reason_len.



132
133
134
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 132

def delivery_failure_reason_len
  @delivery_failure_reason_len
end

#message_idObject

Mandatory fields



123
124
125
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 123

def message_id
  @message_id
end

#network_error_codeObject

Returns the value of attribute network_error_code.



128
129
130
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 128

def network_error_code
  @network_error_code
end

#network_error_code_lenObject

Returns the value of attribute network_error_code_len.



133
134
135
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 133

def network_error_code_len
  @network_error_code_len
end

Instance Method Details

#decode_packet(decoder) ⇒ Object

Interface to decode SMPP packet



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 57

def decode_packet(decoder)
	# Decode header and mandatory fields
	@header = decoder.decode_header()
	@message_id = decoder.decode_message_id(command_length())
	
	# Decode optional fields
	while decoder.has_tlvs() 
		case decoder.get_tlv_code()
			when OptTags::TAG_ADDITIONAL_STATUS_INFO_TEXT
				@additional_status_info_text, @additional_status_info_text_len = 
					decoder.decode_additional_status_info_text(command_length())
			when OptTags::TAG_DELIVERY_FAILURE_REASON
				@delivery_failure_reason, @delivery_failure_reason_len = 
					decoder.decode_delivery_failure_reason(command_length())
			when OptTags::TAG_NETWORK_ERROR_CODE
				@network_error_code, @network_error_code_len = 
					decoder.decode_network_error_code(command_length())
			else
				# Report about error
				raise Errors::UNKNOWN_TAG_MSG + decoder.get_tlv_error()
		end
	end
end

#encode_packet(encoder) ⇒ Object

Interface to encode SMPP packet



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 42

def encode_packet(encoder)
	# Encode header and mandatory fields
	encoder.encode_header(@header)
	encoder.encode_message_id(@message_id)
  
	# Encode optional fields
	encoder.encode_additional_status_info_text(@additional_status_info_text, 
		@additional_status_info_text_len) if !@additional_status_info_text.nil?
	encoder.encode_delivery_failure_reason(@delivery_failure_reason, 
		@delivery_failure_reason_len) if !@delivery_failure_reason.nil?
	encoder.encode_network_error_code(@network_error_code, 
		@network_error_code_len) if !@network_error_code.nil?
end

#output_packet(outputter) ⇒ Object

Interface to output SMPP packet



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 100

def output_packet(outputter)
	# Output header and mandatory fields
	outputter.output_header(@header)
	outputter.output_message_id(@message_id)
  
	# Output optional fields
	outputter.output_additional_status_info_text(@additional_status_info_text, 
		@additional_status_info_text_len) if !@additional_status_info_text.nil?
	outputter.output_delivery_failure_reason(@delivery_failure_reason, 
		@delivery_failure_reason_len) if !@delivery_failure_reason.nil?
	outputter.output_network_error_code(@network_error_code, 
		@network_error_code_len) if !@network_error_code.nil?
end

#validate_packet(validator) ⇒ Object

Interface to validate SMPP packet



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/pdu/smpp_deliver_sm_resp.rb', line 82

def validate_packet(validator)
	# Validate header and mandatory fields
	validator.validate_header(@header)
	validator.validate_message_id(@message_id)
  
	# Validate optional fields
	validator.validate_additional_status_info_text(@additional_status_info_text, 
		@additional_status_info_text_len) if !@additional_status_info_text.nil?
	validator.validate_delivery_failure_reason(@delivery_failure_reason, 
		@delivery_failure_reason_len) if !@delivery_failure_reason.nil?
	validator.validate_network_error_code(@network_error_code, 
		@network_error_code_len) if !@network_error_code.nil?
  
	# Validate compex rules
	validator.validate_message_id_null(message_id)
end