Class: Cwmp::Acs

Inherits:
Object
  • Object
show all
Defined in:
lib/cwmp/acs.rb

Instance Method Summary collapse

Constructor Details

#initialize(port) ⇒ Acs

Returns a new instance of Acs.



56
57
58
59
60
61
62
# File 'lib/cwmp/acs.rb', line 56

def initialize (port)
    @port = port
    @app = HttpRouter.new do
        # add('/api').to(SocketApp.new)
        add('/acs').to(Handler.new)
    end
end

Instance Method Details

#startObject



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/cwmp/acs.rb', line 89

def start
    @web = Thread.new do
        Thin::Logging.silent = true
        Rack::Handler::Thin.run @app, :Port => @port
    end

    Thread.new do
        while true do
            sleep 1
            Readline.clear_rl
            puts "i"
            Readline.restore
        end
    end
    start_cli
end

#start_cliObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/cwmp/acs.rb', line 64

def start_cli

    list = [
        'GetParameterValues', 'SetParameterValues', 'Reboot', 'FactoryReset', 'Download', 'AddObject', 'DeleteObject',
        'help', 'quit', "waitMessage"
    ].sort

    comp = proc { |s| list.grep(/^#{Regexp.escape(s)}/) }

    ::Readline.completion_append_character = " "
    ::Readline.completion_proc = comp

    while line = ::Readline.readline('> ', true)
        case line
            when "quit"
                puts "Bye"
                exit(0)
            when "help"
                help
            when "list"
                puts "list"
        end
    end
end