class Dovado::Router

A Dovado Router.

@since 1.0.0

Public Class Methods

new(args=nil) click to toggle source

Create a new {Router} object representing an actual Dovado router on the local network.

The default router options are:

  • Address: 192.168.0.1

  • Port: 6435

  • User: admin

  • Password: password

@param [Hash] args optional arguments. @option args [String] :address IP address or DNS name @option args [Integer] :port Port which the router is listening on @option args [String] :user User name @option args [String] :password Password

# File lib/dovado/router.rb, line 22
def initialize(args=nil)
  @address    = '192.168.0.1' # Default address
  @port       = 6435
  @user        = "admin"       # Default username
  @password    = "password"    # Default password
  @connected  = false
  unless args.nil?
    @address  = args[:address]  if args.has_key? :address
    @port     = args[:port]     if args.has_key? :port
    @user      = args[:user]     if args.has_key? :user
    @password  = args[:password] if args.has_key? :password
  end

  supervise_client
end

Public Instance Methods

info() click to toggle source

Fetch information from the router.

@return [Info] The {Info} object. @see {Info}

# File lib/dovado/router.rb, line 84
def info
  Info.setup_supervision!
  client = Actor[:client]
  router_info = Actor[:router_info]
  router_info.update! unless router_info.valid?

  services
  router_info
rescue ConnectionError => ex
  Actor[:client].terminate
  supervise_client
  supervise_info
  raise ex
end
internet() click to toggle source

Get the Internet Connection object. @since 1.0.2 @return [Internet] the Internet Connection object. @see {Internet}

# File lib/dovado/router.rb, line 66
def internet
  Internet.setup_supervision!
  Actor[:internet]
end
services() click to toggle source

Fetch services information from the router.

@return [Services] The {Services} object @see {Services}

# File lib/dovado/router.rb, line 42
def services
  Services.setup_supervision!
  client = Actor[:client]
  router_services = Actor[:router_services]

  router_services.update! unless router_services.valid?

  if router_services[:sms] == 'enabled'
    
    Sms.setup_supervision!
    sms.enabled = true
  end
  router_services
rescue ConnectionError => ex
  Actor[:client].terminate
  supervise_client
  supervise_services
  raise ex
end
sms() click to toggle source

Fetch text messages from the router.

@return [Sms] The {Sms} object. @see {Sms}

# File lib/dovado/router.rb, line 103
def sms
  Sms.supervise as: :sms, size: 1 unless Actor[:sms]
  Actor[:sms]
end
traffic() click to toggle source

Get the Data Traffic object. @since 1.0.2 @return [Traffic] the Data Traffic object @see {Traffic}

# File lib/dovado/router.rb, line 75
def traffic
  Traffic.setup_supervision!
  Actor[:traffic]
end

Private Instance Methods

supervise_client() click to toggle source
# File lib/dovado/router.rb, line 110
def supervise_client
  args = [{
    server:     @address,
    port:       @port,
    user:       @user,
    password:   @password
  }]

  return Client.supervise as: :client, size: 1, args: args unless Actor[:client]
  return Client.supervise as: :client, size: 1, args: args if Actor[:router_services] and Actor[:router_services].dead?
end