Class: SmscManager::SmsSendTopic

Inherits:
StompMessage::StompSendTopic
  • Object
show all
Defined in:
lib/smsc_manager/sms_send_topic.rb

Constant Summary collapse

@@TOPIC =

need to define topic, host properly

'/topic/sms'
@@STOMP_SMS_MESSAGE =

must be defined as method in sms_listener

'stomp_SMS'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SmsSendTopic

Returns a new instance of SmsSendTopic.



15
16
17
18
19
20
21
22
# File 'lib/smsc_manager/sms_send_topic.rb', line 15

def initialize(options={})
 # set up variables using hash
  options[:topic] =   options[:topic]==nil ? @@TOPIC : options[:topic]
 
  super(options)
  
  #puts "finished initializing"
end

Class Method Details

.create_stomp_message(txt, dest, src) ⇒ Object

simple script to show xml message



51
52
53
54
# File 'lib/smsc_manager/sms_send_topic.rb', line 51

def self.create_stomp_message(txt,dest,src)
 sms=SmscManager::Sms.new(txt,dest,src)
 m=StompMessage::Message.new(@@STOMP_SMS_MESSAGE, sms.to_xml)
end


55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/smsc_manager/sms_send_topic.rb', line 55

def self.print_example_xml
   text= "hello there #{Time.now}"
   destination = "639993130030"  #must be valid destination
   source = '888'
   sms=SmscManager::Sms.new(text,destination,source)
   m=SmscManager::SmsSendTopic.create_stomp_message( text,destination,source)
   result = "------------ SMS XML----------------\n"
   result << "#{sms.to_xml}\n"
   result << "------------STOMP XML--------------\n"
   result << "#{m.to_xml}\n"
   result << "------------END--------------------"
   result
end

Instance Method Details

#send_sms(text, destination, source) ⇒ Object

puts “finished initializing”

end


28
29
30
31
# File 'lib/smsc_manager/sms_send_topic.rb', line 28

def send_sms(text,destination,source)
       sms=SmscManager::Sms.new(text,destination,source)
       self.send_topic_sms(sms)
end

#send_topic_sms(sms) ⇒ Object

send_sms



32
33
34
35
36
37
38
39
40
# File 'lib/smsc_manager/sms_send_topic.rb', line 32

def send_topic_sms(sms)
       #sms=SmscManager::Sms.new(text,destination,source)
      # msgbody=sms.to_xml
       m=StompMessage::Message.new(@@STOMP_SMS_MESSAGE, sms.to_xml)
    #   puts "message body is #{msgbody}"
      # headers = {:msisdn =>"#{sms.destination}"}
       headers = {}
       send_topic(m, headers)     
end

#send_topic_sms_receipt(sms, &r_block) ⇒ Object

send_sms



41
42
43
44
45
46
47
48
49
# File 'lib/smsc_manager/sms_send_topic.rb', line 41

def send_topic_sms_receipt(sms, &r_block)
       #sms=SmscManager::Sms.new(text,destination,source)
      # msgbody=sms.to_xml
       m=StompMessage::Message.new(@@STOMP_SMS_MESSAGE, sms.to_xml)
    #   puts "message body is #{msgbody}"
      # headers = {:msisdn =>"#{sms.destination}"}
        headers = {}
       send_topic(m, headers, &r_block)     
end