Class: Majoron::AntHill::SMPP::SMPPDataSMResp

Inherits:
SMPPResp show all
Defined in:
lib/pdu/smpp_data_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) ⇒ SMPPDataSMResp

Constructor.



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

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

Instance Attribute Details

#additional_status_info_textObject

Returns the value of attribute additional_status_info_text.



136
137
138
# File 'lib/pdu/smpp_data_sm_resp.rb', line 136

def additional_status_info_text
  @additional_status_info_text
end

#additional_status_info_text_lenObject

Returns the value of attribute additional_status_info_text_len.



142
143
144
# File 'lib/pdu/smpp_data_sm_resp.rb', line 142

def additional_status_info_text_len
  @additional_status_info_text_len
end

#delivery_failure_reasonObject

Optional fields



134
135
136
# File 'lib/pdu/smpp_data_sm_resp.rb', line 134

def delivery_failure_reason
  @delivery_failure_reason
end

#delivery_failure_reason_lenObject

Optional fields length



140
141
142
# File 'lib/pdu/smpp_data_sm_resp.rb', line 140

def delivery_failure_reason_len
  @delivery_failure_reason_len
end

#dpf_resultObject

Returns the value of attribute dpf_result.



137
138
139
# File 'lib/pdu/smpp_data_sm_resp.rb', line 137

def dpf_result
  @dpf_result
end

#dpf_result_lenObject

Returns the value of attribute dpf_result_len.



143
144
145
# File 'lib/pdu/smpp_data_sm_resp.rb', line 143

def dpf_result_len
  @dpf_result_len
end

#message_idObject

Mandatory fields



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

def message_id
  @message_id
end

#network_error_codeObject

Returns the value of attribute network_error_code.



135
136
137
# File 'lib/pdu/smpp_data_sm_resp.rb', line 135

def network_error_code
  @network_error_code
end

#network_error_code_lenObject

Returns the value of attribute network_error_code_len.



141
142
143
# File 'lib/pdu/smpp_data_sm_resp.rb', line 141

def network_error_code_len
  @network_error_code_len
end

Instance Method Details

#decode_packet(decoder) ⇒ Object

Interface to decode SMPP packet



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/pdu/smpp_data_sm_resp.rb', line 61

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_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())
			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_DPF_RESULT
				@dpf_result, @dpf_result_len = 
					decoder.decode_dpf_result(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



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pdu/smpp_data_sm_resp.rb', line 43

def encode_packet(encoder)
	# Encode header and mandatory fields
	encoder.encode_header(@header)
	encoder.encode_message_id(@message_id)
  
	# Encode optional fields
	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?
	encoder.encode_additional_status_info_text(@additional_status_info_text, 
		@additional_status_info_text_len) if !@additional_status_info_text.nil?
	encoder.encode_dpf_result(@dpf_result, 
		@dpf_result_len) if !@dpf_result.nil?
  
end

#output_packet(outputter) ⇒ Object

Interface to output SMPP packet



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/pdu/smpp_data_sm_resp.rb', line 106

def output_packet(outputter)
			# Output header and mandatory fields
			outputter.output_header(@header)
			outputter.output_message_id(@message_id)
  
			# Output optional fields
	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?
	outputter.output_additional_status_info_text(@additional_status_info_text, 
		@additional_status_info_text_len) if !@additional_status_info_text.nil?
	outputter.output_dpf_result(@dpf_result, 
		@dpf_result_len) if !@dpf_result.nil?
end

#validate_packet(validator) ⇒ Object

Interface to validate SMPP packet



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/pdu/smpp_data_sm_resp.rb', line 89

def validate_packet(validator)
	# Validate header and mandatory fields
	validator.validate_header(@header)
	validator.validate_message_id(@message_id)
  
	# Validate optional fields
	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?
	validator.validate_additional_status_info_text(@additional_status_info_text, 
		@additional_status_info_text_len) if !@additional_status_info_text.nil?
	validator.validate_dpf_result(@dpf_result, 
		@dpf_result_len) if !@dpf_result.nil?
end