Class: SmscManager::SmscConnection
- Inherits:
-
Object
- Object
- SmscManager::SmscConnection
- Defined in:
- lib/smsc_manager/smsc_connection.rb
Constant Summary collapse
- @@timeout_max =
use block for timers etc
10
Instance Attribute Summary collapse
-
#hostname ⇒ Object
10 second timeout to contact sms server.
-
#password ⇒ Object
10 second timeout to contact sms server.
-
#port ⇒ Object
10 second timeout to contact sms server.
-
#username ⇒ Object
10 second timeout to contact sms server.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
- #send(sms) ⇒ Object
-
#send_block(text, destination, source) ⇒ Object
def intialize(pass, user, port=13013, host=‘localhost’) end.
- #test(sms) ⇒ Object
Instance Attribute Details
#hostname ⇒ Object
10 second timeout to contact sms server
9 10 11 |
# File 'lib/smsc_manager/smsc_connection.rb', line 9 def hostname @hostname end |
#password ⇒ Object
10 second timeout to contact sms server
9 10 11 |
# File 'lib/smsc_manager/smsc_connection.rb', line 9 def password @password end |
#port ⇒ Object
10 second timeout to contact sms server
9 10 11 |
# File 'lib/smsc_manager/smsc_connection.rb', line 9 def port @port end |
#username ⇒ Object
10 second timeout to contact sms server
9 10 11 |
# File 'lib/smsc_manager/smsc_connection.rb', line 9 def username @username end |
Class Method Details
.factory ⇒ Object
65 66 67 |
# File 'lib/smsc_manager/smsc_connection.rb', line 65 def self.factory SmscManager::SmscConnection.load_smsc end |
.load_smsc ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/smsc_manager/smsc_connection.rb', line 40 def self.load_smsc #change this in database or here test_path=self.path_to_config # puts "Path to config file is: #{test_path}" config = File.open(test_path) { |f| YAML.load(f) } #puts "config is: #{config} config.class is: #{config.class}" if config.class==SmscManager::SmscConnection smsc=config else # puts "hostname is: #{config['hostname']}" smsc=SmscManager::SmscConnection.new smsc.hostname=config["hostname"] smsc.port=config["port"] smsc.username=config["username"] smsc.password=config["password"] end smsc end |
.path_to_config ⇒ Object
30 31 32 |
# File 'lib/smsc_manager/smsc_connection.rb', line 30 def self.path_to_config File.join(File.dirname(__FILE__), '../../config/smsc.yml') end |
Instance Method Details
#dump ⇒ Object
34 35 36 37 38 39 |
# File 'lib/smsc_manager/smsc_connection.rb', line 34 def dump #change this in database or here test_path=SmscManager::SmscConnection.path_to_config # puts "Path to config file is: #{test_path}" config = File.open(test_path,'w') { |f| YAML.dump(self,f) } end |
#send(sms) ⇒ Object
59 60 61 |
# File 'lib/smsc_manager/smsc_connection.rb', line 59 def send(sms) sms_send(sms) end |
#send_block(text, destination, source) ⇒ Object
def intialize(pass, user, port=13013, host=‘localhost’) end
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/smsc_manager/smsc_connection.rb', line 13 def send_block(text,destination,source) @flag=false s = Time.now #max forty second timeout @res='before' begin Timeout::timeout(@@timeout_max) { @res= yield } rescue Exception => e @res = "#{e}" ensure s= Time.now - s end # puts "#{Time.now} result #{hostname} flag: #{flag} res: #{res} time #{s}" puts "-res #{@res} -time #{s} dest: #{destination} src: #{source}" return @res end |
#test(sms) ⇒ Object
62 63 64 |
# File 'lib/smsc_manager/smsc_connection.rb', line 62 def test(sms) send(sms) end |