Class: SmscManager::SmscListener

Inherits:
StompMessage::StompZActiveRecordServer
  • Object
show all
Defined in:
lib/smsc_manager/smsc_listener.rb

Constant Summary collapse

SLEEP_TIME =

sleep x seconds to slow down system

1/@@MAX_THROUGHPUT
@@MAX_THROUGHPUT =

in messages per second

5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SmscListener

need to define topic, host properly @@TOPIC=‘/topic/sms’



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

def initialize(options={})
  self.model_list = []
  self.model_list << "sms_log.rb"
  super(options)
  #self.smsc=SmscManager::SmscConnection.factory
  puts "finished initializing"
end

Instance Attribute Details

#smscObject

Returns the value of attribute smsc.



12
13
14
# File 'lib/smsc_manager/smsc_listener.rb', line 12

def smsc
  @smsc
end

Instance Method Details

#archive_sms(res, sms) ⇒ Object



22
23
24
25
26
# File 'lib/smsc_manager/smsc_listener.rb', line 22

def archive_sms(res,sms)
  # do I need to do exception handling in here
  flag= res.kind_of? Net::HTTPResponse
  SmsLog.log_result(res, 'stomp_message', sms,flag )
end

#setup_thread_specific_items(mythread_number) ⇒ Object



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

def setup_thread_specific_items(mythread_number)
  super(mythread_number)
  puts " ----creating smsc for #{Thread.current[:name]}"
  Thread.current[:smsc]= SmscManager::SmscConnection.factory
end

#stomp_SMS(msg, stomp_msg) ⇒ Object



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

def stomp_SMS(msg, stomp_msg)
   sms=SmscManager::Sms.load_xml(msg.body)
    puts "#{Thread.current[:name]}sending sms #{msg.body}" if @debug
   res= Thread.current[:smsc].send(sms)
   archive_sms(res,sms)
 #  sleep(SLEEP_TIME)  #only 5 messages per second max
end