Class: Dovado::Router

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/dovado/router.rb,
lib/dovado/router/sms.rb,
lib/dovado/router/info.rb,
lib/dovado/router/traffic.rb,
lib/dovado/router/internet.rb,
lib/dovado/router/services.rb,
lib/dovado/router/info/signal.rb,
lib/dovado/router/sms/message.rb,
lib/dovado/router/sms/messages.rb,
lib/dovado/router/info/operator.rb,
lib/dovado/router/traffic/amount.rb,
lib/dovado/router/info/operator/telia.rb

Overview

A Dovado Router.

Since:

  • 1.0.0

Defined Under Namespace

Classes: Info, Internet, Services, Sms, Traffic

Instance Method Summary collapse

Constructor Details

#initialize(args = nil) ⇒ Router

Create a new Dovado::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

Parameters:

  • args (Hash) (defaults to: nil)

    optional arguments.

Options Hash (args):

  • :address (String)

    IP address or DNS name

  • :port (Integer)

    Port which the router is listening on

  • :user (String)

    User name

  • :password (String)

    Password

Since:

  • 1.0.0



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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

Instance Method Details

#infoInfo

Fetch information from the router.

Returns:

See Also:

  • {Info}

Since:

  • 1.0.0



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/dovado/router.rb', line 89

def info
  supervise_info
  router_info = Actor[:router_info]
  client = Actor[:client]
  router_info = Actor[:router_info]
  unless router_info.valid?
    client.connect unless client.connected?
    client.authenticate unless client.authenticated?
    info = client.command('info')
    router_info.create_from_string info
  end
  services
  router_info
rescue ConnectionError => ex
  Actor[:client].terminate
  supervise_client
  supervise_info
  raise ex
end

#internetInternet

Get the Internet Connection object.

Returns:

  • (Internet)

    the Internet Connection object.

See Also:

  • {Internet}

Since:

  • 1.0.2



71
72
73
74
# File 'lib/dovado/router.rb', line 71

def internet
  Internet.supervise as: :internet, size: 1 unless Actor[:internet]
  Actor[:internet]
end

#servicesServices

Fetch services information from the router.

Returns:

See Also:

  • {Services}

Since:

  • 1.0.0



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/dovado/router.rb', line 42

def services
  supervise_services
  client = Actor[:client]
  router_services = Actor[:router_services]

  unless router_services.valid?
    client.connect unless client.connected?
    client.authenticate unless client.authenticated?
    string = client.command('services')
    router_services.create_from_string string
  end

  if router_services[:sms] == 'enabled'
    
    Sms.supervise as: :sms, size: 1 unless Actor[:sms]
    sms.enabled = true
  end
  router_services
rescue ConnectionError => ex
  Actor[:client].terminate
  supervise_client
  supervise_services
  raise ex
end

#smsSms

Fetch text messages from the router.

Returns:

See Also:

  • {Sms}

Since:

  • 1.0.0



113
114
115
116
# File 'lib/dovado/router.rb', line 113

def sms
  Sms.supervise as: :sms, size: 1 unless Actor[:sms]
  Actor[:sms]
end

#trafficTraffic

Get the Data Traffic object.

Returns:

  • (Traffic)

    the Data Traffic object

See Also:

  • {Traffic}

Since:

  • 1.0.2



80
81
82
83
# File 'lib/dovado/router.rb', line 80

def traffic
  Traffic.supervise as: :traffic, size: 1 unless Actor[:traffic]
  Actor[:traffic]
end