Class: Majoron::AntHill::SMPP::SMPPQueryBroadcastSMResp

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

Constructor.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 24

def initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil)
	super(CommandId::CM_QUERY_BROADCAST_SM_RESP, command_status, sequence_number)
  
	# Mandatory fields
	@message_id = ""
	@message_state = nil
	@broadcast_area_identifier = nil
	@broadcast_area_success = nil
  
  
	# Mandatory fields len
	@message_state_len = SMPPTLVLen::BYTE_LEN
	@broadcast_area_identifier_len = SMPPTLVLen::ZERO_LEN
	@broadcast_area_success_len = SMPPTLVLen::BYTE_LEN
  
	# Optional fields
	@user_message_reference = nil
	@broadcast_end_time = nil
  
	# Optional fields length
	@user_message_reference_len = SMPPTLVLen::WORD_LEN
	@brodcast_end_time_len = SMPPTLVLen::ZERO_LEN
  
end

Instance Attribute Details

#broadcast_area_identifierObject

Returns the value of attribute broadcast_area_identifier.



173
174
175
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 173

def broadcast_area_identifier
  @broadcast_area_identifier
end

#broadcast_area_identifier_lenObject

Returns the value of attribute broadcast_area_identifier_len.



178
179
180
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 178

def broadcast_area_identifier_len
  @broadcast_area_identifier_len
end

#broadcast_area_successObject

Returns the value of attribute broadcast_area_success.



174
175
176
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 174

def broadcast_area_success
  @broadcast_area_success
end

#broadcast_area_success_lenObject

Returns the value of attribute broadcast_area_success_len.



179
180
181
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 179

def broadcast_area_success_len
  @broadcast_area_success_len
end

#broadcast_end_timeObject

Returns the value of attribute broadcast_end_time.



183
184
185
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 183

def broadcast_end_time
  @broadcast_end_time
end

#broadcast_end_time_lenObject

Returns the value of attribute broadcast_end_time_len.



187
188
189
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 187

def broadcast_end_time_len
  @broadcast_end_time_len
end

#message_idObject

Mandatory fields



171
172
173
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 171

def message_id
  @message_id
end

#message_stateObject

Returns the value of attribute message_state.



172
173
174
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 172

def message_state
  @message_state
end

#message_state_lenObject

Mandatory fields len



177
178
179
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 177

def message_state_len
  @message_state_len
end

#user_message_referenceObject

Optional fields



182
183
184
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 182

def user_message_reference
  @user_message_reference
end

#user_message_reference_lenObject

Optional fields length



186
187
188
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 186

def user_message_reference_len
  @user_message_reference_len
end

Instance Method Details

#decode_packet(decoder) ⇒ Object

Interface to decode SMPP packet



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 72

def decode_packet(decoder)
	# Decode header and mandatory fields
	@header = decoder.decode_header()
	@message_id = decoder.decode_message_id(command_length())
  
	# Decode mandatory fields as TLV structures
	if decoder.has_tlvs() && decoder.get_tlv_code() == OptTags::TAG_MESSAGE_STATE
		@message_state, @message_state_len = 
			decoder.decode_message_state_tlv(command_length())
	end
  
	while decoder.has_tlvs() && decoder.get_tlv_code() == OptTags::TAG_BROADCAST_AREA_IDENTIFIER
		id, len = decoder.decode_broadcast_area_identifier(command_length())
		if @broadcast_area_identifier.nil? || @broadcast_area_identifier_len.nil?
			@broadcast_area_identifier = []
			@broadcast_area_identifier_len = []
		end
		@broadcast_area_identifier << id
		@broadcast_area_identifier_len << len
	end
  
	if decoder.has_tlvs() && decoder.get_tlv_code() == OptTags::TAG_BROADCAST_AREA_SUCCESS
		@broadcast_area_success, @broadcast_area_success_len = 
			decoder.decode_broadcast_area_success(command_length())
	end
  
	# Decode optional fields
	while decoder.has_tlvs() 
		case decoder.get_tlv_code()
			when OptTags::TAG_USER_MESSAGE_REFERENCE
				@user_message_reference, @user_message_reference_len = 
					decoder.decode_user_message_reference(command_length())
			when OptTags::TAG_BROADCAST_END_TIME
				@broadcast_end_time, @broadcast_end_time_len = 
					decoder.decode_broadcast_end_time(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



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 50

def encode_packet(encoder)
	# Encode header and mandatory fields
	encoder.encode_header(@header)
	encoder.encode_message_id(@message_id)
  
	# Encode mandatory fields as TLV structures
	encoder.encode_message_state_tlv(@message_state,
		@message_state_len)
	encoder.encode_broadcast_area_identifier(@broadcast_area_identifier,
		@broadcast_area_identifier_len)
	encoder.encode_broadcast_area_success(@broadcast_area_success,
		@broadcast_area_success_len)
  
	# Encode optional fields
	encoder.encode_user_message_reference(@user_message_reference, 
		@user_message_reference_len) if !@user_message_reference.nil?
	encoder.encode_broadcast_end_time(@broadcast_end_time, 
		@broadcast_end_time_len) if !@broadcast_end_time.nil?
  
end

#output_packet(outputter) ⇒ Object

Interface to output SMPP packet



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 136

def output_packet(outputter)
	# Output header and mandatory fields
	outputter.output_header(@header)
	outputter.output_message_id(@message_id)
  
	# Output mandatory fields as TLV structures
	outputter.output_message_state_tlv(@message_state,
		@message_state_len)
	outputter.output_broadcast_area_identifier(@broadcast_area_identifier,
		@broadcast_area_identifier_len)
	outputter.output_broadcast_area_success(@broadcast_area_success,
		@broadcast_area_success_len)
  
	# Output optional fields
	outputter.output_user_message_reference(@user_message_reference, 
		@user_message_reference_len) if !@user_message_reference.nil?
	outputter.output_broadcast_end_time(@broadcast_end_time, 
		@broadcast_end_time_len) if !@broadcast_end_time.nil?
end

#validate_packet(validator) ⇒ Object

Interface to validate SMPP packet



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/pdu/smpp_query_broadcast_sm_resp.rb', line 115

def validate_packet(validator)
	# Validate header and mandatory fields
	validator.validate_header(@header)
	validator.validate_message_id(@message_id)
  
	# Validate mandatory fields as TLV structures
	validator.validate_message_state_tlv(@message_state,
		@message_state_len)
	validator.validate_broadcast_area_identifier(@broadcast_area_identifier,
		@broadcast_area_identifier_len)
	validator.validate_broadcast_area_success(@broadcast_area_success,
		@broadcast_area_success_len)
  
	# Validate optional fields
	validator.validate_user_message_reference(@user_message_reference, 
		@user_message_reference_len) if !@user_message_reference.nil?
	validator.validate_broadcast_end_time(@broadcast_end_time, 
		@broadcast_end_time_len) if !@broadcast_end_time.nil?
end