Class: Lokii::GsmServer
- Defined in:
- lib/lokii/servers/gsm_server.rb
Overview
The gsm server operates against connected gsm modem(s). If the ports property is specified in the settings it will try to pool connections to the various ports, otherwise it will attempt to auto-detect
Instance Attribute Summary collapse
-
#proxies ⇒ Object
readonly
Returns the value of attribute proxies.
Attributes inherited from Server
Instance Method Summary collapse
Methods inherited from Server
#complete, #daemon?, #disconnect, #process, #ready?, #running?, #setup, #stopped?
Instance Attribute Details
#proxies ⇒ Object (readonly)
Returns the value of attribute proxies.
11 12 13 |
# File 'lib/lokii/servers/gsm_server.rb', line 11 def proxies @proxies end |
Instance Method Details
#check ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/lokii/servers/gsm_server.rb', line 25 def check self.proxies.each {|proxy| proxy..each {|| handle() } } end |
#connect ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lokii/servers/gsm_server.rb', line 13 def connect Lokii::Logger.debug "Connecting" modems = [] ports = Lokii::Config.ports.split(',') rescue [] ports.each {|port| modems << Gsm::Modem.new(port) } modems = [Gsm::Modem.new] if modems.empty? modems.each {|modem| modem.encoding = Lokii::Config.encoding.to_sym} if Lokii::Config.encoding modems.each {|modem| modem.keep_inbox_empty = true} @proxies = modems.map{|modem| Lokii::GsmProxy.new(modem) } @current = 0 end |
#say(text, number, reply = nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/lokii/servers/gsm_server.rb', line 33 def say(text, number, reply = nil) @current += 1 @current = 0 if @current > proxies.size - 1 @proxies[@current].outgoing(number, text) end |