smsc_manager 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.txt CHANGED
@@ -1,5 +1,8 @@
1
1
  README for smsc_manager
2
2
  =======================
3
+
4
+
5
+
3
6
  For more info: www.ficonab.com
4
7
  scott.sproule@gmail.com
5
8
 
data/Rakefile CHANGED
@@ -46,6 +46,8 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
46
46
  p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
47
47
  p.test_globs = ["test/**/*_test.rb"]
48
48
  p.clean_globs = CLEAN #An array of file patterns to delete on clean.
49
+ p.extra_deps = [ ['stomp_message', '>= 0.0.5'] ]
50
+
49
51
 
50
52
  # == Optional
51
53
  #p.changes - A description of the release's latest changes.
data/bin/sms_om_server.rb CHANGED
@@ -11,7 +11,8 @@ require 'smsc_manager'
11
11
 
12
12
  puts "Starting Operational Measurement (OM) server:"
13
13
  # begin
14
- sms_listener=SmscManager::SmsStatisticsListener.new.run
14
+ # can add additional options to change host/port etc
15
+ sms_listener=SmscManager::SmsStatisticsListener.new({:topic => '/topic/sms'}).run
15
16
  sms_listener.join
16
17
  # rescue Exception => e
17
18
  puts "exception found #{e.backtrace}"
@@ -11,7 +11,7 @@ require 'smsc_manager'
11
11
 
12
12
  puts "Starting topic server:"
13
13
  # begin
14
- SmscManager::SmscListener.new.run
14
+ SmscManager::SmscListener.new({:topic => '/topic/sms'}).run
15
15
  # sms_listener.join
16
16
  # rescue Exception => e
17
17
  puts "exception found #{e.backtrace}"
@@ -14,6 +14,7 @@ require 'daemons'
14
14
 
15
15
  }
16
16
  Daemons.run(File.join(File.dirname(__FILE__), 'sms_topic_server.rb'), options)
17
+
17
18
 
18
19
 
19
20
 
@@ -1,5 +1,8 @@
1
1
  require 'rexml/document'
2
2
  # Sms stuff for handling sms
3
+ require 'rubygems'
4
+ gem 'stomp_message'
5
+ require 'stomp_message'
3
6
  module SmscManager
4
7
  class InvalidPrefix < RuntimeError
5
8
  end
@@ -12,6 +15,7 @@ class Sms
12
15
  def self.max_length
13
16
  @@MAX_SIZE
14
17
  end
18
+ include StompMessage::XmlHelper
15
19
  # create new sms, limit the text, src is 1000
16
20
  def self.valid
17
21
  sentence=" "
@@ -37,6 +41,13 @@ class Sms
37
41
  flag
38
42
  end
39
43
  def to_xml
44
+ msg_xml = REXML::Element.new "sms"
45
+ msg_xml =self.add_elements(msg_xml)
46
+ msg_xml.to_s
47
+ # doc= REXML::Document.new sms_xml.to_s
48
+ # doc.to_s
49
+ end
50
+ def to_xml_old
40
51
  sms_xml = REXML::Element.new "sms"
41
52
  destination_xml = REXML::Element.new "destination"
42
53
  destination_xml.text=self.destination
@@ -4,69 +4,37 @@ gem 'stomp'
4
4
  require 'stomp'
5
5
  gem 'stomp_message'
6
6
  require 'stomp_message'
7
+ # class to manage statistics
7
8
  module SmscManager
8
- class SmsStatisticsListener
9
- @@MAX_THROUGHPUT =5 # in messages per second
10
- attr_accessor :conn, :count, :source, :topic
9
+ class SmsStatisticsListener < StompMessage::StompStatisticsServer
10
+
11
11
  #need to define topic, host properly
12
12
 
13
13
  @debug=false
14
- def initialize
15
- self.topic='/topic/sms'
16
- puts "in intialize topic #{self.topic}"
17
- self.conn = Stomp::Connection.open '', '', 'localhost', 61613, false
18
- self.count = 0
19
- self.conn.subscribe self.topic, { :ack =>"auto" }
20
- self.source ={}
14
+ def initialize(options={})
15
+ super(options)
16
+ # self.source ={}
17
+
18
+
21
19
  puts "finished initializing"
22
20
  end
23
- def statistics(sms)
24
- self.count+=1
25
- self.source[sms.source] = 0 if !self.source.key?(sms.source)
26
- self.source[sms.source] += 1
21
+ def create_m_statistics(sms)
22
+ # self.source[sms.source] = 0 if !self.source.key?(sms.source)
23
+ # self.source[sms.source] += 1
27
24
  end
28
- def stomp_REPORT(msg)
29
- puts "#{self.topic} OM Report: #{Time.now}"
30
- puts "message count is: #{count}"
31
- self.source.each_pair {|i,val|
32
- puts " source #{i} count #{val}"
33
- }
25
+ def stomp_REPORT(msg, stomp_msg)
26
+ super(msg, stomp_msg)
27
+ puts " --------------------------------- details"
28
+ # self.source.each_pair { |key,val| puts " key: #{key} value: #{val}"}
29
+ # puts " --------------------------------- "
34
30
  end
35
- def stomp_SMS(msg)
36
- puts "msg command #{msg.command} msg body #{msg.body}"
31
+ def stomp_SMS(msg, stomp_msg)
32
+ puts "msg command #{msg.command} msg body #{msg.body}" if @debug
37
33
  sms=SmscManager::Sms.load_xml(msg.body)
38
- statistics(sms)
34
+ create_m_statistics(sms)
39
35
  puts "#{self.topic} OM report stomp_SMS" if @debug
40
- stomp_REPORT(msg) if self.count % 100 == 0
41
- end
42
- def stomp_DEBUG(msg)
43
- @debug=!@debug
44
- puts "debug flag is now #{@debug}"
45
- end
46
- def method_missing(name, *args)
47
- puts "Method missing called: #{name}"
48
- puts "Likely invalid message recived"
49
- end
50
- def run
51
- # Thread.new {
52
- while true #loop forever
53
- # puts "before receive"
54
- msg = self.conn.receive
55
- # puts "after receive"
56
- begin
57
- puts "STOMP message frame is : #{msg} "
58
- m=StompMessage::Message.load_xml(msg.body)
59
- # puts "Message is: #{m.to_xml}" if @debug
60
- puts "Message type is #{m.command}" if @debug
61
- self.send(m.command,m)
62
- rescue Exception => e
63
- puts "exception found #{e.backtrace}"
64
- puts "exception messae #{e.msg}"
65
- end
66
- end # while
67
- # }
68
- # t.join # wait for t to die..
69
- end #run
36
+ stomp_REPORT(msg) if self.msg_count % 100 == 0
37
+ end
70
38
  end # smsc listener
71
39
 
72
40
  end #module
@@ -6,56 +6,26 @@ require 'stomp'
6
6
  gem 'stomp_message'
7
7
  require 'stomp_message'
8
8
  module SmscManager
9
- class SmscListener
9
+ class SmscListener < StompMessage::StompServer
10
10
  @@MAX_THROUGHPUT =5 # in messages per second
11
11
  SLEEP_TIME=1/@@MAX_THROUGHPUT #sleep x seconds to slow down system
12
- attr_accessor :conn, :smsc, :count
12
+ attr_accessor :smsc
13
13
  #need to define topic, host properly
14
- @@TOPIC='/topic/sms'
15
- @debug=false
16
- def initialize
17
- self.conn = Stomp::Connection.open '', '', 'localhost', 61613, false
18
- self.count = 0
19
- self.conn.subscribe @@TOPIC, { :ack =>"auto" }
14
+ # @@TOPIC='/topic/sms'
15
+ def initialize(options={})
16
+ super(options)
20
17
  self.smsc=SmscManager::SmscConnection.factory
21
18
  puts "finished initializing"
22
19
  end
23
20
  # name is message command
24
- def stomp_SMS(msg)
21
+ def stomp_SMS(msg, stomp_msg)
25
22
  sms=SmscManager::Sms.load_xml(msg.body)
26
- puts "sending sms #{msg.body}"
23
+ puts "sending sms #{msg.body}" if @debug
27
24
  res= self.smsc.send(sms)
28
25
 
29
26
  sleep(SLEEP_TIME) #only 5 messages per second max
30
27
  end
31
- def stomp_DEBUG(msg)
32
- @debug=!@debug
33
- puts "debug flag is now #{@debug}"
34
- end
35
- def method_missing(name, *args)
36
- puts "Method missing called: #{name}"
37
- puts "Likely invalid message recived"
38
- end
39
- def run
40
-
41
- while true #loop forever
42
- # puts "before receive"
43
- msg = self.conn.receive
44
- # puts "after receive"
45
- begin
46
- # puts "STOMP message frame is : #{msg} " if @debug
47
- m=StompMessage::Message.load_xml(msg.body)
48
- # puts "Message is: #{m.to_xml}" if @debug
49
- puts "Message type is #{m.command}" if @debug
50
- self.send(m.command,m) # effectively case statement (Should SCREEN HERE)
51
- # puts "sms text is: #{sms.text} dest is: #{sms.destination} result is: #{res}"
52
- rescue Exception => e
53
- puts "exception found #{e.backtrace}"
54
- end
55
- end # while
56
-
57
- # t.join # wait for t to die..
58
- end #run
28
+
59
29
  end # smsc listener
60
30
 
61
31
  end #module
@@ -2,7 +2,7 @@ module SmscManager #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: smsc_manager
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.4
7
- date: 2007-09-19 00:00:00 +08:00
6
+ version: 0.4.5
7
+ date: 2007-09-24 00:00:00 +08:00
8
8
  summary: connection to smsc via http using kannel
9
9
  require_paths:
10
10
  - lib
@@ -80,5 +80,13 @@ extensions: []
80
80
 
81
81
  requirements: []
82
82
 
83
- dependencies: []
84
-
83
+ dependencies:
84
+ - !ruby/object:Gem::Dependency
85
+ name: stomp_message
86
+ version_requirement:
87
+ version_requirements: !ruby/object:Gem::Version::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: 0.0.5
92
+ version: