Class: SmscManager::SmscStompConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/smsc_manager/smsc_stomp_connection.rb

Constant Summary collapse

@@timeout_max =

use block for timers etc

10

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostnameObject

10 second timeout to contact sms server



9
10
11
# File 'lib/smsc_manager/smsc_stomp_connection.rb', line 9

def hostname
  @hostname
end

#passwordObject

10 second timeout to contact sms server



9
10
11
# File 'lib/smsc_manager/smsc_stomp_connection.rb', line 9

def password
  @password
end

#portObject

10 second timeout to contact sms server



9
10
11
# File 'lib/smsc_manager/smsc_stomp_connection.rb', line 9

def port
  @port
end

#topicObject

10 second timeout to contact sms server



9
10
11
# File 'lib/smsc_manager/smsc_stomp_connection.rb', line 9

def topic
  @topic
end

#urlObject

10 second timeout to contact sms server



9
10
11
# File 'lib/smsc_manager/smsc_stomp_connection.rb', line 9

def url
  @url
end

#usernameObject

10 second timeout to contact sms server



9
10
11
# File 'lib/smsc_manager/smsc_stomp_connection.rb', line 9

def username
  @username
end

Instance Method Details

#intialize(args) ⇒ Object



10
11
12
13
14
15
# File 'lib/smsc_manager/smsc_stomp_connection.rb', line 10

def intialize(args)
  self.url="/TopicSMS/TopicSMS"
  self.topic = 'sms'
  self.hostname = 'x.x.x.x'
  self.port='8161'
end

#send(sms) ⇒ Object



17
18
19
# File 'lib/smsc_manager/smsc_stomp_connection.rb', line 17

def send(sms)
  sms_send(sms)
end

#sms_send(sms) ⇒ Object

asssumes http post — can be modified for other messaging of course



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

def sms_send(sms)
   puts "create stomp message"
   m=SmscManager::SmsSendTopic.create_stomp_message(sms.text,sms.destination,sms.source)
   puts "message is #{m.to_xml}"
   # original puts "hostname: #{arg_hash[:host]} port #{arg_hash[:port]}"
   arg_hash={}
   arg_hash[:host]=self.hostname
   argh_hash[:port]=self.port
      puts "hostname: #{self.hostname} port #{arg_hash[:port]}"
   url="#{arg_hash[:topic]}?m.to_xml"
   arg_hash[:url]=self.url
   arg_hash[:topic]=self.topic
     msg_sender=StompMessage::StompSendTopic.new(arg_hash) 
     msg_sender.post_stomp(m, {})
end

#test(sms) ⇒ Object



20
21
22
# File 'lib/smsc_manager/smsc_stomp_connection.rb', line 20

def test(sms)
   send(sms)
end